How can I auto refresh OAuth 2.0 token once the token expires.?

How can I auto refresh OAuth 2.0 token once the token expires. ?

Hi @pranavNathcorp :wave:

Welcome to Postman Community!

At this point, it isn’t possible to auto-refresh the oAuth2.0 token, and we are having this as a feature request which is being tracked on our GitHub page, and our engineering team is working on it. Please subscribe to it to get updates and do provide your comments/feedback directly there. Hope this helps!

1 Like

@allenheltondev wrote this post about a workaround for token renewal:

2 Likes

@danny-dainton
Is there any way I can explicitly expire the token and check whether the script is working or not ?

Changing my system time ,will it effect the token to expire ?

I guess you could lower the expires in time in the environment variable so that it refreshes sooner?

The decision to run the token creation again would be based on comparing the time now to the time set to expire.

Yup, this is the right answer. You could remove the expires variable completely and it will renew it for you.

Can you please help me how can I remove the expires variable.?
I don’t want it manually to be done.

But I thought you just wanted to remove it to check if the script was working?

If you want to not have that variable set, then your options are to either not set it in the first place or to call the unset function in a script somewhere.

Does Postman support auto refreshing expired OAuth2 tokens natively? Or is it best to use @allenheltondev’s Pre-Request Script to renew tokens at the collection level?

Thanks in advance.

Please check this feature request : Auto update of OAuth2 access tokens · Issue #10112 · postmanlabs/postman-app-support (github.com)

Hello,
I’m not sure if you’ve come across this already, but in v10.6.0, auto-refresh for OAuth2 tokens is handled :blush: Here’s a video tutorial for how to use it:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.