【问题标题】:Zoho OAuth 2.0 Refresh token multiple timesZoho OAuth 2.0 多次刷新令牌
【发布时间】:2020-11-10 00:07:25
【问题描述】:

我正在使用 Zoho OAuth 2.0,并按照https://www.zoho.com/crm/help/api/v2/#oauth-request 中的步骤获取访问令牌和刷新令牌。但是我有一些问题。

这是一个场景:

1. Get authorization token
2. From authorization token, get  access token and refresh token.
3. After one hour, I use the refresh token. (then I receive a new access token) - As stated here https://www.zoho.com/crm/help/api/v2/#refreshing-tokens
4. After that, another hour, how is it possible for me to get another access token? As refresh token expires in an hour (similar to access token I assume).
5. When I refresh token, only a new access token is given but not a new refresh token. So after one hour I cannot do another refresh again.

有人知道如何实现吗?

【问题讨论】:

    标签: java oauth-2.0 access-token zoho refresh-token


    【解决方案1】:

    我自己也有类似的用例,我必须说它的文档记录很差。您的应用程序应该有一个“静态”刷新令牌,并使用它每小时生成一个新的访问令牌。

    授权 ----> 刷新 --(每小时)--> 访问

    因此,对于我的后端,我使用预先生成的刷新令牌并在该小时的时间到时生成访问令牌。使用此访问令牌与 API 进行正常交互。

    我建议您阅读来自多个 Zoho 模块的文档,因为它们很差,即使您只使用一个模块,您也可能需要多个示例才能真正理解它(大多数情况下,身份验证部分实际上是相同的)。你可以开始herehere

    【讨论】:

      【解决方案2】:

      Zoho 一个账户只提供一次刷新令牌。所以我们必须保存该刷新令牌以获取新的访问令牌。

      【讨论】:

        【解决方案3】:

        使用这个函数来创建一个新的访问令牌。在访问令牌过期之前,您必须每隔一小时调用一次此方法。它会为您生成一个新的访问令牌

        function generateAuthTokenfromRefreshToken(test){    ZCRMRestClient.generateAuthTokenfromRefreshToken(process.env.ADMIN_EMAIL_ADDRESS,process.env.REFRESH_TOKEN).then(function(auth_response){
                 process.env.OAUTH_TOKEN=auth_response.access_token;         
                 logger.log('info', ` new_outh_token :${auth_response.access_token}`);                 
         })
        

        【讨论】:

          猜你喜欢
          • 2015-11-04
          • 2014-09-22
          • 2015-05-17
          • 1970-01-01
          • 2015-04-01
          • 2020-09-01
          • 2017-01-11
          • 2014-11-22
          • 1970-01-01
          相关资源
          最近更新 更多