在Refresh token is not returned from Dropbox API when using grant_type=refresh_token
发帖人问他为什么在使用新的 dropbox v2 api 时没有获得新的刷新令牌。
答案是不需要。除非被撤销,否则刷新令牌不会从 Dropbox 过期。
还是这样吗?我正在阅读https://developers.dropbox.com/oauth-guide
“当使用刷新令牌时,您使用授权代码的 grant_type 调用 /oauth2/token 端点将返回一个新的短期访问令牌和一个新的刷新令牌,这些令牌应该被安全存储。”
但是当我使用刷新令牌获取访问令牌时仍然没有看到刷新令牌。
Request:
POST https://api.dropbox.com/oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: api.dropbox.com
Content-Length: 363
Expect: 100-continue
Connection: Keep-Alive
refresh_token=<TOKEN>&grant_type=refresh_token&client_id=<ID>&client_secret=<Secret>&scope=account_info.write+account_info.read+files.metadata.write+files.metadata.read+files.content.write+files.content.read+sharing.write+sharing.read+file_requests.write+file_requests.read+contacts.write
Response
HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Type: text/javascript
Date: Thu, 29 Apr 2021 13:30:50 GMT
Pragma: no-cache
Server: envoy
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Server-Response-Time: 35
Vary: Accept-Encoding
X-Dropbox-Response-Origin: far_remote
X-Dropbox-Request-Id: 744233e362ac4b20a00e7a862ae90a16
Content-Length: 395
{"token_type": "bearer", "access_token": "token", "expires_in": 14400, "scope": "account_info.read contacts.write file_requests.read file_requests.write files.content.read files.content.write files.metadata.read files.metadata.write sharing.read sharing.write"}
我正在使用 .net api 将我的刷新令牌交换为访问令牌。但是,即使它在线路上,也不知道我是如何取回新的刷新令牌的。它似乎不是。当我使用刷新令牌获取访问令牌时,刷新令牌本身似乎不会过期。将来会改变吗?
_DropBoxClient = new DropboxClient(string.Empty, dbap.RefreshToken, sApiKey, sApiSecret, config);
var newScopes = new string[]
{
"account_info.write",
"account_info.read",
"files.metadata.write",
"files.metadata.read",
"files.content.write",
"files.content.read",
"sharing.write",
"sharing.read",
"file_requests.write",
"file_requests.read",
"contacts.write"
};
bool success = Task.Run<bool>(async () => await _DropBoxClient.RefreshAccessToken(newScopes)).Result;
答案 0 :(得分:0)
Dropbox API /oauth2/token 端点在刷新过程中不会返回新的刷新令牌,也没有计划这样做。官方documentation for the Dropbox /oauth2/token endpoint can be found here。
Dropbox OAuth 指南指的是当您为 grant_type=authorization_code
调用 /oauth2/token 时,即第一次交换短期令牌和(可选)刷新令牌的授权代码时。 (抱歉,这里的“新”字有误导性。我们会解决这个问题。)
当您为 grant_type=refresh_token
调用 /oauth2/token 时,即使用刷新令牌获取新的短期访问令牌时,它不会返回另一个刷新令牌。