Getting Error while generating access token

Hi Team,

While trying to generate access token, I am getting UDAPI100057 Error.
I have generated the code correctly using my redirect url.

But, My access token is getting generated only once; If I again try to hit it again it is throwing above error.

@Ketan , Any here please ?

The auth code for generating the access token is for one-time use only. To generate a new access token, you must repeat the login flow and obtain a new auth code as outlined here.

Hi @Pradeep_Jaiswar ,

Yes I have done what you have mentioned. I got the access token. And I have used the same access token and used it to get LTP and OPTION CHAIN Data. Immediately Iā€™m getting the above error in postman.

Attaching SS for your reference :

Please help me.

Also, For me while generating access token, The user_type field is mentiond as ā€œmulticlientā€. Not sure if that helps you.
It has to be ā€œIndividualā€ rite if Iā€™m not wrong ?

@Pramod_kalyan_P Could you provide the complete cURL request below for review? It seems like something might be missing.

You can also refer to the example code available here: Full Market Quotes | Upstox Developer API.

Hi @Pradeep_Jaiswar ,

This is the URL Iā€™m hitting,

https://api.upstox.com/v2/market-quote/ltp?instrument_key=NSE_EQ|INE0J0B01017

https://api.upstox.com/v2/login/authorization/token?code=ā€œ--ā€&client_id=ā€œ--ā€&client_secret=ā€œ--ā€&redirect_uri=https://sample.edu/day&grant_type=authorization_code

Import below in postman and try

curl -X 'POST' 'https://api.upstox.com/v2/login/authorization/token' \
-H 'accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'code={your_code}&client_id={your_client_id}&client_secret={your_client_secret}&redirect_uri={your_redirect_url}&grant_type=authorization_code'

Okey Will Import and update you

@Pradeep_Jaiswar ,

Still No luck same Issue.

Also, For me while generating access token, The user_type field is mentiond as ā€œmulticlientā€. Not sure if that helps you.
It has to be ā€œIndividualā€ rite if Iā€™m not wrong ?

Do you this may the reason ?

user_type is not the issue. Kindly provide your complete CURL request here for review.

curl --location --request POST ā€˜https://api.upstox.com/v2/login/authorization/token?code=edeHmt&client_id=edb6fbad-7fb8-4baf-8a91-0e4583b4ea3f&client_secret=ā€œ**ā€&redirect_uri=https%3A%2F%2Fsample.edu%2Fday&grant_type=authorization_codeā€™ \

ā€“header ā€˜Content-Type: application/x-www-form-urlencodedā€™ \

ā€“header ā€˜Accept: application/jsonā€™ \

@Pradeep_Jaiswar

curl --location ā€˜https://api.upstox.com/v2/market-quote/ltp?instrument_key=NSE_EQ|INE0J0B01017ā€™
ā€“header 'Authorization: ā€™
ā€“header ā€˜Accept: application/jsonā€™
ā€“header ā€˜Cookie: __cf_bm=_F2iLTbxVhXgpjNNVkNYbsIjdsVy0Yl0hgrZhqOeRv0-1734090671-1.0.1.1-bN.qBq3Mvnwdsl7HGpOPjkC_Urpk7ewbMjrRsEqddA_n.42uMtJpjdDigz3qoIO.; _cfuvid=DScwdgXD7eUhCgYo8606H3pfdu9eP8Na_MloC91HE3E-1734084842289-0.0.1.1-604800000; udapi_api_key=edb6fbad-7fb8-4baf-8a91-0e4583b4ea3fā€™

For the Get Token API, your parameters must be included in the body with the Content-Type set to application/x-www-form-urlencoded. Refer to the CURL request below:

curl --location 'https://api.upstox.com/v2/login/authorization/token' \
--header 'accept: application/json' \
--header 'Api-Version: 2.0' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'code={your_onetime_auth_code}' \
--data-urlencode 'client_id={your_client_id}' \
--data-urlencode 'client_secret={your_client_secret}' \
--data-urlencode 'redirect_uri={your_client_redirect_uri}' \
--data-urlencode 'grant_type=authorization_code'

For the Market Quote API, include the Authorization header with the prefix Bearer followed by your access token, as shown below:

curl --location 'https://api.upstox.com/v2/market-quote/ltp?symbol=NSE_EQ%7CINE036D01028' \
--header 'accept: application/json' \
--header 'Api-Version: 2.0' \
--header 'Authorization: Bearer {your_access_token}'

This will solve your problem.

Kindly refrain from sharing your access token in any public domain.

Hi @Pradeep_Jaiswar , Now Iā€™m able to see the response.

Thank you so much your help and your time.

1 Like