APIs & Integrations

lybek76
Member

Access token expiry

SOLVE

I have an integration in place and I've already implemented the programmatical refresh of the access token before the expiry time. 
However, i would like to add a safeguard in case this primary refreshing method fails.

That would rely on knowing the specific format of the response in case of any request that is executed with an expired access token - could you provide that please? I cannot find any information on it from docs.

 

One more question - is there a way to manually expire the access token (for testing purposes)? 

 

 

0 Upvotes
1 Accepted solution
himanshurauthan
Solution
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Access token expiry

SOLVE

Hello @lybek76 

 

On making an API call with expired token, a status code 40X is returned with a proper response/error message that Access token is expired. Its not feasible to rely on specific format response. Instead you can make a check before every call if your access token in valid or not with the help of expires_in parameter value that is returned while auth process.

You can save expires_in value as like current timeStamp + expires_in into a DB record. And before making each call do a check if current timeStamp > Saved value into DB, then refresh the access token else you can continue with same token.

 

Thanks

Digital Marketing & Inbound Expert In Growth Hacking Technology

View solution in original post

8 Replies 8
SGupta88
Member

Access token expiry

SOLVE

Hey, I am in need to know that which API will regenerate the access token for me if my previous one got expired. I am checking its expiry by expires_In but now i dont know which API to call to get a new access token. Can you please provide me with that endpoint and its details? Thanks

0 Upvotes
himanshurauthan
Solution
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Access token expiry

SOLVE

Hello @lybek76 

 

On making an API call with expired token, a status code 40X is returned with a proper response/error message that Access token is expired. Its not feasible to rely on specific format response. Instead you can make a check before every call if your access token in valid or not with the help of expires_in parameter value that is returned while auth process.

You can save expires_in value as like current timeStamp + expires_in into a DB record. And before making each call do a check if current timeStamp > Saved value into DB, then refresh the access token else you can continue with same token.

 

Thanks

Digital Marketing & Inbound Expert In Growth Hacking Technology
SGupta88
Member

Access token expiry

SOLVE

Hey, I am in need to know that which API will regenerate the access token for me if my previous one got expired. I am checking its expiry by expires_In but now i dont know which API to call to get a new access token. Can you please provide me with that endpoint and its details? Thanks

0 Upvotes
lybek76
Member

Access token expiry

SOLVE

That's exactly what I'm doing now, I just thought about creating a safeguard just in case something goes wrong with token refreshing. 

You can never be too safe 😉

himanshurauthan
Thought Leader | Elite Partner
Thought Leader | Elite Partner

Access token expiry

SOLVE
Hello,

Yes either you can compare for expiry time or even more safe method will be to refresh token on when only few seconds left in expiry. This will never lead to any dead call with the access token expiry.

Thanks
Digital Marketing & Inbound Expert In Growth Hacking Technology
blainenye
Participant

Access token expiry

SOLVE

Thanks for the approach to refreshing the token.

 

Is there a way to force a token to expire for testing?

 

Blaine 

0 Upvotes
lybek76
Member

Access token expiry

SOLVE

You can refresh your access token which will expire the old one automatically.

blainenye
Participant

Access token expiry

SOLVE

Thanks Lybek, I was actually hoping to just be able to set the expiration time to 0 to test that case of handling an expired access token. I ended up just noting another expired token and testing with that.

 

Blaine

0 Upvotes