search

getAccessToken API

Use Case

Using this API merchant can get the access token corresponding to a Auth Code (received from the App side in earlier step). For the same merchant backend needs to make a S2S call with Paytm backend. This token can be used to fetch the User details in the getUserInfo API.

Request Attributes

API Content format: JSON

Head

ATTRIBUTEDESCRIPTIONMANDATORY
AuthorizationThis is a base64 encoded string of “clientId:clientSecret”Yes

Body

ATTRIBUTEDESCRIPTIONEXAMPLE
codeauthorization_codeauthorization_code
grant_typeAuth code you get in response from paytmFetchAuthCode bridgerwtw-fsdfk-vcvx-tweq
client_idClient ID provided during onboarding your Mini Appschant-abc
scopescope of the Mini AppsBasic

Response Attributes

Head

ATTRIBUTEDESCRIPTIONEXAMPLE
statusstatus of response200

Success:

PARAMETERDESCRIPTIONEXAMPLE VALUE
scopescope of the Mini Appspaytm
access_tokenaccess token of the user sent by paytm7522b293-cad6-4ed8-bdc6-7c3bc3637100
expiresexpiration time1570465786000
resourceOwnerIdResource owner IDXXXXXX

Error Responses:

PARAMETERDESCRIPTIONEXAMPLE VALUE
errorerror nameInternal error
error_descriptionerror messageSomething went wrong

Error Codes

STATUSERROR
400Internal Error
400unsupported_grant_type
400invalid_grant
401NO RESPONSE BODY
UAT
Production
https://accounts-uat.paytm.com/oauth2/v2/token
copy content icon
REQUEST CODE
RESPONSE CODE
CURL
JAVASCRIPT
copy content icon
curl -X POST 
'https://accounts.paytm.com/oauth2/v2/token' 
 --header 'Content-Type: application/x-www-
form-urlencoded'  --header 'cache-control: no-
cache'  --header 'Authorization: Basic 
YWxhZGRpbjpvcGVuc2VzYW1l' --data
'grant_type= authorization_code&code=rwtw-
fsdfk-vcvx-tweq&client_id=mmerchant-
abc&scope=basic'