search

paytmFetchAuthCode JS API

Use Case

This API can be used to get AuthCode and OpenID for the user accessing the Mini Apps. when merchants front-end calls this method, Paytm will show the user a popup asking for permission to share these details. If the user allows on the consent popup same will be shared with the merchants. If the user denies, ideal expectation is for Merchants to call the API again.


Please Note: No Manual Login from the user is allowed in the Mini Apps platform.




AuthCode:This is a one time use AuthCode passed by Paytm to the merchant’s Mini Apps frontend/client codebase via JS API. This has a validity of 5 mins and is for single use only. This code is required to fetch the Paytm AuthToken via S2S call with Paytm’s Oauth backend.


OpenId: This is a unique user identifier passed by Paytm to Mini Apps. It remains the same throughout the lifetime of the user.

Request Attributes

API Content format: JSON

PARAMETERDESCRIPTIONREQUIREDEXAMPLE VALUE
clientIdMerchant's client id received from paytmYesmerchant-xyz

Response Attributes

Success

Note: Response will come as JSON with key data.


PARAMETERDESCRIPTIONEXAMPLE VALUE
data.authIdauthId generated by paytmabhd-jhsd-ujyt-afrw
data.openIdopenId generated by paytmabhdjhsd860154

Error Responses:

Note: Response will come as JSON with key data.


PARAMETERDESCRIPTIONEXAMPLE VALUE
errorerror code in integers-3
errorMessageerror messageInvalid clientID

Error Codes

ERRORMESSAGE
0"Unable to process your request"
2"clientID not passed"
-1"User denied consent"
-2"user login failed"
-3"Invalid clientID"
-4"Invalid token"(Check Consent Status API failed)
-5"Failed to save consent"
-6"Invalid clientID"
-7"Invalid token"(Fetch Authcode API failed)
-8"Device Not Verified"
-9"Invalid Authorisation"
-10"Failed to fetch AuthCode"
-11"user consent failure"
-12"Invalid clientId"
-13""Invalid SSO token""
-14""Failed to fetch OpenID""
REQUEST CODE
RESPONSE CODE
JAVASCRIPT
copy content icon

function ready (callback) { 
     // call if jsbridge is injected
     if
      callback && callback();
    } else{// listen to jsbridge ready event
    
     document.addEventListener('JSBridgeReady',
     callback, false);
    }}
        
    ready(function () {
     JSBridge.call('paytmFetchAuthCode',{
       clientId:"/*your reqClient ID*/"},
       function(result) {
       console.log(JSON.stringify(result))
      });
    });