My question:I am Using Oauth 2.0 for my project , where Access token gets expired every 19 mins , I have to go and click on Get New Access Token Every time . Refresh Token is not working . can anybody please guide me to refresh Token
I’m having the same issue. This used to work until I updated Postman yesterday. Currently I’m on 10.10.5, not sure what version I was running before though
The oAuth provider needs to return a refresh token as well as the access token. If you request a token with Postman, or if you use “Manage Access Tokens” you should see both the access and refresh tokens. If it just has the access token the oAuth provider isnt returning the refresh token. Once a refresh token has been acquired the “Auto-refresh token” option will be enabled.
When using Microsoft Azure as an oAuth2.0 provider you need to use offline_access in the scope. This will need to be configured in your app registration too.
For other providers the scopes will be different. Review their documentation or contact their support.
Doesn’t work for me either.
My provider doesn’t return a refresh token, I just hit the same URL again to get a new token.
I get why @Moodie007 says that the oAuth provider should provide a refresh token, but if they don’t, why can’t Postman just hit the same URL again for me?
It should refresh in the same way that it does when I click Get New Access Token.
…refresh tokens will never be granted with this flow as client_id and client_secret (which would be required to obtain a refresh token) can be used to obtain an access token instead.
In this case the offline_access scope will not help and Postman should preferably just call the token endpoint to get a new access token instead.
All,
I discovered this after I realised our provider doesn’t provide an Access token. Is there any way to automate this request? Perhaps as a pre-request script?
I’ve never had any luck using this approach, I found a script on here years ago and have continued to use it, as its reliable.
I use the code below in the Collection Re-requests script to check if the token is still valid and if it’s not then it will renew the token automatically before making the actual request.
The authData variable contains the clientId:clientSecret base64 encoded
the script will store the access token (jwt) as an environment variable so it can be added to all requests that require it, or add it to the collection or folder-level authentication tab if you need it on all requests,
If your auth service is different to this one, you may need to tweak the request header or body for it to work.