Repository navigation
Conversation
When an API call returns 401 expired_access_token, the retry loop in request_json_string_with_retry refreshed the access token without the scope given to Dropbox(scope=...). The token request then had no "scope" field, so the new token carried every scope of the original grant. Pass self._scope, as check_and_refresh_access_token already does.
|
Hi @Feldt, I’ve raised this with our engineering team for further review. They’ll be able to review the pull request and address it as appropriate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dropbox(scope=[...])is documented as the "list of scopes to request on refresh".check_and_refresh_access_token()passes it on (refresh_access_token(scope=self._scope)), but the retry inrequest_json_string_with_retry()that runs after a 401expired_access_tokencallsself.refresh_access_token()with no scope. That path runs when the server says the token has expired while the client still thinks it is valid, for example when the local clock is behind or the stored expiration is off. The/oauth2/tokenrequest then has noscopefield, so the new token gets every scope of the original grant instead of the narrower set the client asked for.This change passes
scope=self._scopeon that path too. Clients created withoutscopebehave as before (scope=None, noscopefield sent).Test:
TestClient.test_refresh_on_expired_access_token_uses_client_scopemakes the first request raiseAuthErrorwithexpired_access_token, lets the retry succeed, and checks the refresh POST body. Onmainit fails withassert None == 'files.metadata.read files.metadata.write'; with the fix it passes.I prepared this change with an AI coding agent (Claude Code), and the agent ran the checks:
toxwith the fullenvlist(py311, py312, py313, pypy3, check, lint, docs, test_unit, coverage) passes, andpytest test/unit/passes (111 tests) on Python 3.11, 3.12 and 3.13. I'm responsible for the change and will answer review.Checklist
General Contributing
Is This a Code Change?
Validation
toxpass?🤖 Generated with Claude Code