简体   繁体   English

在Passport.js中刷新令牌

[英]Refresh token in Passport.js

How do I do this in Passport.js?: 我如何在Passport.js中执行此操作?:

When the access token expires, you can use the refresh_token to "refresh" your access, and gain another access_token. 当访问令牌过期时,您可以使用refresh_token“刷新”您的访问权限,并获得另一个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: 要使用refresh_token,您需要向grant-endpoint执行POST请求,并将grant_type设置为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

I asked Jared if he would consider adding something into the core to make this a little easier to handle. 我问Jared他是否会考虑在核心中添加一些东西以使其更容易处理。 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 所以我写了一个插件来帮助: https//github.com/fiznool/passport-oauth2-refresh

answer from Jared Hanson , author PassportJS : PassportJS作者Jared Hanson的回答:

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. 例如:设置一个cron作业,查询即将到期的令牌,发出POST请求以刷新它们。

Passport doesn't get involved in this process, because its separate from authentication. Passport不参与此过程,因为它与身份验证分开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM