MYKEY Docs
中文English
English
English
  • Introduction
  • Sign in with MYKEY
    • Verify signature at backend server
    • More detailed tech and process of MYKEY login
  • Integrate with MYKEY
    • Multiple ways to integration with MYKEY
    • Mobile Dapp with H5 pages
      • ETH
      • EOS
      • JS Extensions
    • Integration via MYKEY Android SDK
      • Preconditions
      • Initiate SDK
      • Authorize
      • Sign
      • Transfer
      • Call contracts
    • Integration via MYKEY iOS SDK
      • Preconditions
      • Initiate SDK
      • Authorize
      • Sign
      • Transfer
      • Call contracts
    • Web application with scanning qrcode
    • SimpleWallet Protocol Compatible
    • Deeplink Protocol
  • Dive into MYKEY
    • Dive into MYKEY account
    • Classes and methods
      • Android Classes
      • iOS Classes
    • Error Code
    • Identify MYKEY deposit transaction
      • ETH deposit
      • EOS deposit
    • MYKEY Whitepaper
  • KEY ID
    • KEYID ETH Contracts introduction
      • Account Module
      • Account Storage Module
      • Logic Management Module
      • Logic Module
    • Account recovery mechanism
    • KEYID contract upgrade process
    • KEYID contract upgrade records
      • ETH
        • KEY ID Ethereum Contracts Upgrade Pending Time Adjustment
        • KEY ID Ethereum logic contract module upgrade announcement
        • KEY ID Ethereum Contracts Upgrade Pending Time Adjustment
        • KEY ID Ethereum AccountLogic/DualsigsLogic Contracts Upgrade
        • KEY ID Ethereum DappLogic Contract Upgrade
  • Development Resources
    • Ethereum
    • EOS
  • Join Us
    • DApp submit
    • Developers Community
Powered by GitBook
On this page

Was this helpful?

  1. Integrate with MYKEY
  2. Integration via MYKEY iOS SDK

Authorize

PreviousInitiate SDKNextSign

Last updated 4 years ago

Was this helpful?

Pull up MYKEY for authentication binding. See the class definition for the parameters: and

For greater security, dapp can set CallBackUrl for server-side verification.

MYKEY will post the signed data to CallBackUrl which provided by dapp, server-side of DApp should verify the signature, dapp server should query the user's ReserveKey from MYKEY SmartContract data to verify the signature, see detail in .

The format of the data post to CallBackUrl:

{
    "protocol":"",  // protocol name,Use init method, protocol name is 'MYKEY', use initSimple to init, protocol name is 'MYKEYSimple'
    "version":"",   // Version,1.0
    "dapp_key":"",  // DAPP_KEY assigned by MYKEY,contact MYKEY team to apply. In simple mode, it is null
    "uuID":"",      // user id,dapp passed it in init method;In simple mode, it is device id
    "sign":"",      // eos signature, sign data:timestamp + account + uuID + ref
    "ref":"",       // ref, mykey
    "timestamp":"", // UNIX timestamp, accurate to second
    "account":"",    // eos account name
    "chain": ""      // value could be ANY, EOS, ETH,or not pass this param
}

Verify signature:

// generate unsignedMessage
let unsignedData = timestamp + account + uuID + ref
// publicKey: ReserveKey of MYKEY,can be quired from SmartContract https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata
ecc.verify(signature, unsignedData, pubkey) === true

dapp should provide response of CallBackUrl call to MYKEY:

{
    "code":0,       // error code,=0 is success. >0, dapp should describe error in message.
    "message":""    // message
}

Sample:

let authorizeRequest = AuthorizeRequest()
authorizeRequest.userName = "uchihamadara"
authorizeRequest.info = "Test information"
// param:{"protocol": "", "version": "", "dapp_key": "", "uuID": "", "public_key": "", "sign": "", "ref": "", "timestamp": "", "account": ""}
// return: same as SimpleWallet {"code": [0-2], "message": ""}
authorizeRequest.callbackUrl = "https://dappserver.xxx.url"

MYKEYWallet.shared.authorize(authorizeRequest: authorizeRequest, response: MYKEYResponse.init(success: { (response) in
    self.view.makeToast("success")
}, failure: { (errorValue) in
    self.view.makeToast("failure")
}, cancelled: {
    self.view.makeToast("cancelled")
}))
AuthorizeRequest
MYKEYResponse
KEYS in MYKEY