我可以使用多少次从Google API获得的刷新令牌 [英] How many times can I use a refresh token obtained from google api

查看:59
本文介绍了我可以使用多少次从Google API获得的刷新令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个Rails应用程序,该应用程序允许用户使用其Google帐户登录,然后该应用程序获取电子邮件并解析它们以获取信息.

I have developed a rails application that allows a user to login using their google account and then the application fetches the emails and parses them for information.

所有这些都工作正常,但是我面临的访问令牌无效的问题,因此我一直在考虑刷新令牌.我在以下位置找到了一些代码: https://stackoverflow.com/a/14491560/718087

All this works fine, but I am facing issues with access token become invalid, hence I have been looking into refreshing the token. I found some code at: https://stackoverflow.com/a/14491560/718087

使用此代码,我已经可以获得一个有效的新访问令牌.但是我有几个问题:

With this code I have been able to get a new access token that works. But I have a few questions:

  1. 我可以使用多少次第一次获得的相同刷新令牌?还是每次获取新的访问令牌时也需要更新刷新令牌?注意:应用程序已设置为具有脱机访问权限.

  1. How many times can I use the same refresh token I got the first time? or do I need update my refresh token as well, each time I get a new access token? note: application is setup with offline access.

我是否需要在令牌过期之前刷新令牌,否则在旧的访问令牌过期之后它仍会返回给我一个有效的令牌?这将使我能够决定何时刷新令牌-a:在获取电子邮件之前,b:在令牌由于延迟的工作或其他原因过期之前自动(虽然这会增加相当大的开销)

Do I need to refresh the token before it expires or it will still return to me a valid token after the old access token has expired? This will allow me to decide an approach as to when I should refresh the tokens - a: right before fetching the emails, b: automatically before the token expires via delayed jobs or something (this would add quite a overhead though)

我已经阅读了api文档,但找不到这些特定问题的答案.请原谅我过分详细的查询.

I have gone through the api docs but could not find answer to my these specific questions. Please excuse my overly detailed queries.

谢谢, 阿迪亚(Aditya)

Thanks, Aditya

推荐答案

刷新令牌永不过期,除非被用户吊销.您应该安全,永久地存储它.您绝对应该不要一遍又一遍地获取新的刷新令牌,因为每个用户/应用程序组合只能理解一定数量的标记,并且最终旧版本将停止工作.

Refresh tokens never expire, unless revoked by the user. You should store it safely and permanently. You should definitely not go back and get new refresh tokens over and over, because only a certain number can be understanding per user/app combination, and eventually the older ones will stop working.

这篇关于我可以使用多少次从Google API获得的刷新令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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