Fetching User Token
Using the “state” from step 10, “code verifier” from step 12, and the “authorization code” from step 9, you need to make a network call to Truecaller’s backend so as to fetch the access token :
POST https://oauth-account-noneu.truecaller.com/v1/token
Headers
Content-Type*
application/x-www-form-urlencoded
String
Request Body
grant_type
"authorization_code"
// hardcoded value
String
client_id
<YOUR_CLIENT_ID>
code
<USER_AUTHORISATION_CODE>
Authorisation code from TcOAuthData callback from step 9
code_verifier
<YOUR_CODE_VERIFIER>
From step 12
curl --location --request POST 'https://oauth-account-noneu.truecaller.com/v1/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'client_id=<<your-client-id>>' \
--data-urlencode 'code=<<authorization_code>>' \
--data-urlencode 'code_verifier=<<your-code-verifier>>'{
"access_token": "o1a04--7JZl5G--VfhYWSSRqC0K-Xfq9lmeaKw3xlrdBluXBAIiVI",
"expires_in": 3600,
"scope": "openid profile",
"token_type": "Bearer",
"id_token": "eyJhbGciOiJSUzI1Ni..."
}Case 1: Generating the token WITH offline_access for first time. App requested openid profile offline_access (both the Portal toggle and setOAuthScopes() must include it).
Case 2: Using the refresh token to get a NEW access token (offline_access flow, on return) When the user comes back and you need a fresh access token, call the same endpoint with grant_type=refresh_token. Do not send code or code_verifier.
Response — The API returns a new access token and a new refresh token (rotated). Please note that the scope field will be returned as empty in the response.
400: Bad Request - If grant type is not supported 403: Forbidden - If client id is invalid 500: Internal Server Error - Unexpected error on the server side 400: Bad Request - Some of the parameters are empty in the request 403: Forbidden Valid grant type but not allowed for the client 403: Forbidden Invalid auth code provided 403: Forbidden Invalid/expired auth code in provided 403: Forbidden Invalid/expired code verifier is provided 429: Too Many Requests If the number of requests exceeds the allowed limit 503: Service Unavailable Resource unavailable due to server-side issue
Last updated
Was this helpful?