OAuth 2.0 - 何时应该使用刷新令牌来更新访问令牌? [英] OAuth 2.0 - When should an access token be renewed with refresh token?

查看:664
本文介绍了OAuth 2.0 - 何时应该使用刷新令牌来更新访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用OAuth 2.0访问Google API。根据我的理解,我应该使用返回的刷新令牌来更新访问令牌。这应该在它过期之前刷新,还是应该在用户使用已过期的访问令牌来请求api数据?



如果它应该在到期之前完成,我应该只是运行一个cron作业来更新过期的标记吗?



我使用node.js和mongodb,如果这对推荐的解决方案有任何影响。

非常感谢!

解决方案

它应该是无缝的。

当用户使用已过期的访问令牌从API请求数据时,这应该会触发您的框架失败,续订,然后重试。



在我创建的应用程序中不需要任何cron作业或类似的东西。

I'm currently using OAuth 2.0 to access the Google API. From my understanding, I should use the returned refresh token to renew the access token. Should this be refreshed before it expires or should it be when the user requests data from the api using an access token that has expired?

If it should be done before it expires, should I just be running a cron job to update out of date tokens?

I'm using node.js and mongodb, if that has any bearing on the recommended solution.

Thanks a lot!

解决方案

It should be seamless.

When the user requests data from the API using an access token that has expired, this should trigger your framework to fail, renew, then retry.

No need for any cron jobs or stuff like that in the apps i've created.

这篇关于OAuth 2.0 - 何时应该使用刷新令牌来更新访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆