fetchAuthToken

fetchAuthToken

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 the grant token.

As soon as this method is called, SSO pop up will come, showing user options to either “Login” or “Skip” the consent. In the case of “Login” Phonepe server will share you with the user details. In the case of “Skip”, merchants can show their login page to users where they can either log in or create a new account.

780

Usage:

PhonePe.PhonePe.build(PhonePe.Constants.Species.web).then((sdk) => {
	sdk.fetchAuthToken().then((res) => {
		console.log("Grant token data received = " + res)
		alert(res)
	}).catch((err) => {
		console.log("Error occurred while fetching the grant token: " + err)
		alert(err)
	})
})

<html-block html=”

Response Parameter

“>

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

Promise resolve:
{
    "grantToken": "GRT8616a8396e9b3a0899a2a6b06a3845cf0ad3521d0c4a0d5194404fba21a00b7a",
    "expiryInSeconds": 86400
}

Promise reject:
{
  "error_code": "NETWORK_ERROR"
}