Token Generation Issue in PHP

How to generate token in php? What are the User ID and API key here? Is there any format to combine User Id and API Key? Please define one example? Thanks

Comments

  •  
    hi bro, go to API sandbox https://momodeveloper.mtn.com/docs/services/sandbox-provisioning-api/operations/post-v1_0-apiuser> click on Sandbox User Provisioning> click on apiuser> https://momodeveloper.mtn.com/docs/services/sandbox-provisioning-api/operations/post-v1_0-apiuser? generate UUID using this php code function first function gen_uuid() { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', // 32 bits for "time_low" mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), // 16 bits for "time_mid" mt_rand( 0, 0xffff ), // 16 bits for "time_hi_and_version", // four most significant bits holds version number 4 mt_rand( 0, 0x0fff ) | 0x4000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 mt_rand( 0, 0x3fff ) | 0x8000, // 48 bits for "node" mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) ); } echo gen_uuid(); click try it copy and paste your generated UUID in X-Reference-Id header field value input(Make sure you backup your UUID some were like a text file) scroll down to the subscription key and select a primary key for the product you had subscribed for like collections you can also add a call back host like your website but this is option click send and your account will be created at sandbox after that go here https://momodeveloper.mtn.com/docs/services/sandbox-provisioning-api/operations/post-v1_0-apiuser-apikey? to generate the API KEY in X-Reference-Id paramater add the your UUID you used to create the sandbox account in Subscription key select the primary key you used to create the sandbox account of your product and click send you will be issued with the apikey and then go to the product you have been using to create apiuser account sandbox and apikey e.g collection go https://momodeveloper.mtn.com/docs/services/collection/operations/token-POST? and click try it so to generate the token in the Authorization value input we need the base64encode string of base64encode(API_USER_UUID:API_KEY_YOU_GENERATED) use this code make user that your string your string has the word "Basic " at the beginning before pasting it to generate token $USER_ID = 'UUID_USED_IN_CREATING_ACCOUN';//e.g f50d0278-d582-455b-91f3-4892589a33a3 $API_KEY = 'API_KEY_YOU_GENERATED';//e.g 7fdfec36018346a99a6e699205a067d7 $encodedString = base64_encode($USER_ID . ':' . $API_KEY); echo 'Basic ' . $encodedString;//e.g Basic ZjUwZDAyNzgtZDU4Mi00NTViLTkxZjMtNDg5MjU4OWEzM2EzOjdmZGZlYzM2MDE4MzQ2YTk5YTZlNjk5MjA1YTA2N2Q3
    Posted by Hidden Mon, 14 Oct 2019 13:15:59 GMT
  •  
    click send and your token will be generated with expiring time
    Posted by Hidden Mon, 14 Oct 2019 13:17:40 GMT


You're not signed in. Please sign-in to report an issue or post a comment.