Dropbox and Google Drive: the token refresh check fails on text errors and Dropbox refreshes on every 401
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- PHP
- Star
- 43
- Fork
- 22
- Merge trung bình
- 54 phút
- Pull request đã merge (30 ngày)
- 57
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của quantum-php/framework
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
quantum-php/framework#692 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
routing testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
quantum-php/framework#547 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Raise PHPStan to level 9Đang mởrefactoring tech debt
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
quantum-php/framework#693 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
install:debugbar reads the package folder from the working directory and uses the default storage adapterCó thể đã có người làm @armanist đã nhận hôm nay. Đang mởbug console debugbar good first issue
quantum-php/framework#691 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
console enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 74/100
quantum-php/framework#688 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của quantum-php/framework
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
ajeetraina/awesome-docker-sbx#559 ·
-
dependencies enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
novalo-dev/Prestashop-MCP-Server#329 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug origin:interactive status:available
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Ultimate-Multisite/ultimate-multisite#2131 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày