Get Grant Token (Single Sign-On)


Description: This method can be used to verify the identity of a PhonePe user and get his details. The merchant should call this method and get a token, let's call it grant token. Then the merchant would send this token to their server which in turn sends this to the PhonePe server and gets the user details, thereby verifying the identity of the user. See the service call Get User Details (Service).


sdk.fetchGrantToken().then((res) => {
	console.log(grant ‘token data received = ’ + res)
}).catch((err) => {
	console.log(‘Error occured while fetching the grant token’)

Response Parameter

A promise resolution with the grant token. Promise rejection if the grant token fetching failed.

Promise resolve:
  "grantToken": "string",
  "forMerchantId": "string",
  "expiresInSeconds": 0

Promise reject:
  "error_code": "NETWORK_ERROR"