For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

Name
Type
Description

Content-Type*

application/x-www-form-urlencoded

String

Request Body

Name
Type
Description

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.

1:- Refresh token TTL is 14 days, but the token family has an absolute limit of 180 days from the initial token’s creation.

2 :-Whenever new refresh token is used to obtain access token, that will remain active only for 30 seconds after that and can be used 8 times in that 30 seconds window. suppose we have used R1 to make R2, R1 will remain active for 30 seconds and R2 will have TTL of 14 days. If in 30 seconds we have again used R1, then it will generate R3. R2 will be deleted and no longer useful. R3 will be latest. But R1 can only be used 8 times.

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?