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.


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

PARAMETER DESCRIPTION

clientId

mandatory

Merchant's client Id received from Paytm

Example: merchant-xyz

Response Attributes

Success

Note: Response will come as JSON with key data.

PARAMETER DESCRIPTION
data.authId

authId generated by paytm

Example: abhd-jhsd-ujyt-afrw

data.openId

openId generated by paytm

Example: abhdjhsd860154

Error Responses

Note: Response will come as JSON with key data.

 

PARAMETER DESCRIPTION
error

error code in integers

Example: -3 

errorMessage

error message

Example: Invalid clientID

Error Codes

ERROR MESSAGE
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
RESPONSE
JAVASCRIPT
function ready(callback) {
    if (window.JSBridge) {
        callback && callback();
    } else {
        document.addEventListener('JSBridgeReady', callback, false);
    }
}

ready(function () {
    JSBridge.call('paytmFetchAuthCode', {
        clientId: "/*your reqClient ID*/"
    }, function (result) {
        console.log(JSON.stringify(result))
    });
});
copy icon