question

hadjgian avatar image
0 Likes"
hadjgian asked

OAuth Application Token Invalidates after some time in the same day

Hello,

I am trying to move from the Finding API to the Browse API, and it seems that I need to use the OAUTH Application token for my requests in order to get data from the REST API calls.

I have gone to the "Auth Tokens for eBay" section in "developer.ebay.com" and under the "Production" environment I pressed the "Get OAuth Application Token", which produces a token that expires in a year from the day of creation.

I can make requests with that token, but I have noticed that later on in the same day when I try to make new requests I get a 401 error, see below, and I need to create a new application token.

{
    "errors": [
        {
            "errorId": 1001,
            "domain": "OAuth",
            "category": "REQUEST",
            "message": "Invalid access token",
            "longMessage": "Invalid access token. Check the value of the Authorization HTTP request header."
        }
    ]
}

Am I doing something wrong here?

tokenoauth2browse apioauth
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tapdevelop avatar image
1 Like"
tapdevelop answered

You need 3 things:

– An Authorization Code / Key (login and confirmation by user every 18 month)
– Refresh Token (used to generate the Access Token, valid 18 month)
– Access Token (used to access the APIs, valid 2 hours)

If you make an API call and it returns an HTTP code 401 and an error ID 1001, then you have to request the access token again (with your refresh token) and repeat the API call.

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sagar_developersupport avatar image
-1 Like"
sagar_developersupport answered

Hi @hadjgian ,

Application access token expires in 7,200 seconds, meaning this token is valid for two hours from the time it was generated. For continued access after the token expires, you must mint a new token.

Important! Access tokens must be treated as confidential and must not be shared or exposed publicly. For best performance and security, applications should store this token in a static variable and re-use the token while it is valid.

Ref: https://developer.ebay.com/api-docs/static/oauth-client-credentials-grant.html

Best Regards ,
eBay Developer Support

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

lksp-93 avatar image
0 Likes"
lksp-93 answered
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sagar_developersupport avatar image
-1 Like"
sagar_developersupport answered

Hi @lksp-93 ,

I have answered to your query on the same forum.

Thank you

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.