Dropbox and Google Drive: the token refresh check fails on text errors and Dropbox refreshes on every 401
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start in CloudAppTrait::sendRequest() to see how the parsed body reaches accessTokenNeedsRefresh(int $code, ?object $message = null) in DropboxApp and GoogleDriveApp, and in ResponseParser::parseBody() to confirm a non-JSON body comes back as a string. Widen both signatures to mixed and handle only object bodies, then change the Dropbox condition to || so only the tags in ACCESS_TOKEN_STATUS refresh. Done means new tests with a mocked HTTP client cover a 401 with a text body, a 401 with an unrelated .tag, and a 401 with expired_access_token refreshing exactly once.
由索引模型根据 Issue 内容生成。
描述
Summary
The Dropbox and Google Drive storage adapters decide after a failed API request whether the access token must be refreshed. That check fails in two ways.
Problems
-
A
TypeErrorfor an error response that is not JSON.CloudAppTrait::sendRequest()passes the response body toaccessTokenNeedsRefresh(int $code, ?object $message = null)inDropboxAppandGoogleDriveApp.ResponseParser::parseBody()returns an object only for a JSON response and the raw text otherwise, and Dropbox answers some errors withtext/plain. Withstrict_types, the text causes aTypeError(Argument #2 ($message) must be of type ?object, string given) instead of theExceptionwith the API's error text thatsendRequest()throws for errors that are not about the token. -
Dropbox refreshes the token on every 401.
DropboxApp::accessTokenNeedsRefresh()reads:if (!isset($error['.tag']) && !in_array($error['.tag'], self::ACCESS_TOKEN_STATUS)) { return false; } return true;With
&&the method returnstruewhenever the error has a.tag, whatever its value, so a 401 that is not about the token (for example a missing permission) refreshes the token and retries.sendRequest()retries by calling itself, so the same 401 starts the next refresh: the request repeats until PHP gives up. Without a.tag, the code reads$error['.tag']anyway and raises a warning. The condition should use||, so onlyinvalid_access_tokenandexpired_access_tokenrefresh the token.
Both are in 3.1.x as well; they are fixed in 3.2.0.
Fix
accessTokenNeedsRefresh()in both apps accepts the response body as it comes (mixed) and reads the error only from an object; a text body is not a token error, sosendRequest()throws itsExceptionwith that text.DropboxApprefreshes only for the.tagvalues inACCESS_TOKEN_STATUS.- Tests with a mocked HTTP client: a 401 with a text body throws the
Exception; a 401 with another.tagthrows without refreshing; a 401 withexpired_access_tokenrefreshes and retries once.
- 主要语言
- PHP
- 星标
- 43
- 派生
- 22
- 平均合并
- 54 分钟
- 30 天内合并 PR
- 57
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
quantum-php/framework 的其他 Issue
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 78/100
quantum-php/framework#692 ·
维护者通常 1 天内回复
-
routing testing
难度 2/5 1-3 小时 新手友好度 76/100
quantum-php/framework#547 ·
维护者通常 1 天内回复
-
refactoring tech debt
难度 5/5 一周以上 新手友好度 20/100
quantum-php/framework#693 ·
维护者通常 1 天内回复
-
install:debugbar reads the package folder from the working directory and uses the default storage adapter可能已有人在做 @armanist 今天认领。 未关闭bug console debugbar good first issue
quantum-php/framework#691 · 已指派 1 人 ·
维护者通常 1 天内回复
-
console enhancement
难度 4/5 3-5 天 新手友好度 74/100
quantum-php/framework#688 ·
维护者通常 1 天内回复
查看 quantum-php/framework 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 70/100
ajeetraina/awesome-docker-sbx#559 ·
-
dependencies enhancement
难度 2/5 1-3 小时 新手友好度 68/100
novalo-dev/Prestashop-MCP-Server#329 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复
-
bug origin:interactive status:available
难度 2/5 1-3 小时 新手友好度 62/100
Ultimate-Multisite/ultimate-multisite#2131 ·
维护者通常 1 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复