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!

@allen.helton wrote this post about a workaround for token renewal:

1 Like

@dannydainton
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.