正如标题所说,最近Dropbox API改版后,Token开始有过期时间了。
以前如果我不撤销的话,Token可以永久使用。
也许出于安全原因添加了过期时间。
然而,这对于我的应用来说非常不方便。我需要上传文件很长时间(可能一次超过一个月)。
根据当前的API,我只能反复刷新令牌以保持令牌不会过期...
有谁知道是否还有办法在当前的Dropbox API中创建一组不会过期的令牌?
As the title says, after the recent revision of the Dropbox API, the Token started to have an expiration time..
In the past, if I did not revoke, the Token could be used permanently.
Maybe the expiration time is added for security reasons.
However, this is very inconvenient for my application. I will need to upload files for a very long time (maybe for more than a month at a time).
According to the current API, I can only refresh the token repeatedly to keep the token no expires...
Does anyone know if there is still a way to create a set of tokens that will not expire in the current Dropbox API?
发布评论
评论(3)
以下是获取刷新令牌所需执行的全部操作,代码片段采用
C#
第 1 步:访问以下 URL 并完成步骤。在最后一步中,您应该会看到屏幕上打印出
Access Code generated
,复制该代码。第 2 步:使用以下代码获取刷新令牌:(注意:您只需执行一次)
响应应如下所示:
您寻找
refresh_token
。 您应该安全地存储它第 3 步:每当您需要新的访问令牌时,请运行以下代码:
响应应如下所示:
您正在寻找 <代码>access_token。并且还要注意
expires_in
值,您可以而且可能应该将access_token
存储在某种内存缓存中,以防止在每次 API 调用时请求新令牌。这是用于获取新刷新令牌的
curl
。Here is all you need to do to get the refresh token, code snippets are in
C#
Step 1: Visit the following URL and finish the steps. in the final step, you should see the
Access Code Generated
printed on the screen, copy the code.Step 2: Get the refresh token using the following code: (NOTE: you'll only need to do it once)
The response should be something like this:
You're looking for the
refresh_token
. you should securely store itStep 3: Anytime you need a new access token, run the following code:
The response should be something like this:
You're looking for the
access_token
. and also pay attention toexpires_in
value, you can and probably should store theaccess_token
in some sort of memory cache in order to prevent requesting a new token on every API call.Here is the
curl
for getting a new refresh token.Dropbox 正在切换为仅颁发短期访问令牌(和可选的刷新令牌),而不是长期访问令牌。您可以此处找到有关此迁移的更多信息。
不过,应用程序仍然可以通过请求“离线”访问来获得长期访问权限,在这种情况下,应用程序会收到一个“刷新令牌”,可用于根据需要检索新的短期访问令牌,而无需进一步的手动用户干预。您可以在OAuth 指南和授权文档。
作为参考,虽然现在已弃用创建新的长期访问令牌,但我们目前没有计划禁用现有的长期访问令牌。 (如果情况发生变化,我们当然会提前宣布。)在这种情况下,您可以继续使用现有的长期访问令牌而不会中断(如果有的话)。另请注意,更改后您将无法创建新的长期访问令牌。
虽然更改于 2021 年 9 月 30 日开始,但我们正在逐步发布它,因此直到现在您可能还没有看到您的应用受到影响。一旦它应用于您的应用程序,无论您的应用程序的“访问令牌过期”设置如何,它都会适用,并且该设置可能不再适用于您的应用程序。
Dropbox is in the process of switching to only issuing short-lived access tokens (and optional refresh tokens) instead of long-lived access tokens. You can find more information on this migration here.
Apps can still get long-term access by requesting "offline" access though, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. You can find more information in the OAuth Guide and authorization documentation.
For reference, while the creation of new long-lived access tokens is now deprecated, we don't currently have a plan to disable existing long-lived access tokens. (If that changes, we will of course announce that ahead of time.) That being the case, you can continue using existing long-lived access token(s) without interruption, if you have any. Also, note though that after the change you won't be able to create new long-lived access tokens.
While the change began on September 30th 2021, we're releasing it gradually, so you may not have seen your app(s) affected until now. Once it applies to your app, it would apply regardless of the "Access token expiration" setting for your app, and that setting may no longer be available for your app.
我为此创建了一个 GitHub 存储库来处理这个问题。
https://github.com/FranklinThaker/Dropbox-API-Uninterrupted-Access
如果我在此存储库中遗漏了某些内容或需要修复某些内容,请告诉我。谢谢。
我从这里开始遵循官方步骤:
https://www.dropbox.com/developers/documentation/http/documentation
I've created a GitHub repo for this which handles this problem.
https://github.com/FranklinThaker/Dropbox-API-Uninterrupted-Access
let me know if I'm missing something or something needs to be fixed in this repo. Thanks.
I've followed the official steps from here:
https://www.dropbox.com/developers/documentation/http/documentation