Repository navigation
fix(auth): send configured scopes in the OAuth2 client-credentials exchange - #8389
Open
sumedh-aerram wants to merge 2 commits into
Open
sumedh-aerram wants to merge 2 commits into
sumedh-aerram wants to merge 2 commits into
Conversation
…change Pass the configured OAuth2 or OpenID Connect scopes only when fetching a client-credentials token. Keep authorization-code exchange and refresh scope omission unchanged. Fixes google#8388
…redentials-scopes
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Fixes #8388
2. Description of change:
Problem: Configured OAuth2 client-credentials scopes are omitted from the token POST. This grant has no authorization redirect to carry them, so providers can return default permissions or reject the request.
Solution: Pass the space-joined configured scope keys to fetch_token only for client credentials, including configured OpenID Connect scopes. Empty scopes remain absent. Authorization-code exchange and refresh retain their existing scope omission.
Testing Plan
Unit Tests:
python -m pytest -q -p no:cacheprovider tests/unittests/auth: 373 passed, 127 warnings on Python 3.11.Before the fix, the targeted regression/control selection produced 4 failed, 2 passed, 14 deselected. Six real-Authlib wire-body cases cover OAuth2 and OpenID Connect with empty, single, and multiple scopes. The existing authorization-code exchange and refresh scope-omission controls also pass.
Pre-commit passed on every changed file. Mypy passes on the changed production files; explicitly checking changed test files produces the same 31 existing diagnostics as the original files, with zero new errors.
Manual End-to-End (E2E) Tests:
Run the offline reproducer from the linked issue using real Authlib and a mocked requests transport. The POST now contains scope=['read:items'] and the exchange succeeds.
Offline reproduction was executed with corrected expectations after the fix. Live-provider/service end-to-end testing was not performed.
Checklist
Additional context
This preserves the scope-omission behavior for refresh and authorization-code exchange established by #5328 / #5874.