Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh token in Passport.js

How do I do this in Passport.js?:

When the access token expires, you can use the refresh_token to "refresh" your access, and gain another access_token. To use the refresh_token you need to do a POST request to our token-endpoint with the grant_type set to refresh_token:

https://podio.com/oauth/token?grant_type=refresh_token&client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&refresh_token=REFRESH_TOKEN
like image 793
AHOYAHOY Avatar asked Mar 23 '13 23:03

AHOYAHOY


2 Answers

I asked Jared if he would consider adding something into the core to make this a little easier to handle. He responded by saying that this should not be handled in the core.

So I wrote a plugin to help: https://github.com/fiznool/passport-oauth2-refresh

like image 148
Tom Spencer Avatar answered Oct 11 '22 12:10

Tom Spencer


answer from Jared Hanson, author PassportJS:

Refresh tokens are something handled entirely on the backend, and not connected to a user's session. For example: set up a cron job, query for tokens about to expire, make POST requests to refresh them.

Passport doesn't get involved in this process, because its separate from authentication.

like image 33
AHOYAHOY Avatar answered Oct 11 '22 14:10

AHOYAHOY