[codex] Support redirect_uri config in Google userFromCode flow#303
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds compatibility for Google OAuth configs that use the standard redirect_uri key so userFromCode() includes redirect_uri during the token exchange, preventing Google “Missing parameter: redirect_uri” failures.
Changes:
- Add a Google provider constructor fallback mapping
redirect_uri→redirect_urlwhen no redirect is otherwise configured. - Add a provider-level test asserting the token request includes
redirect_uriwhen onlyredirect_uriis supplied in config.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Providers/Google.php |
Adds config fallback so Google token exchange includes redirect_uri when configured via redirect_uri. |
tests/Providers/GoogleTest.php |
New test covering userFromCode() token request body includes redirect_uri from config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
When users configure OAuth with
redirect_urionly, token exchange inuserFromCode()could missredirect_uriin the token request body (for example, Google returningMissing parameter: redirect_uri).Root Cause
Internal config normalization used legacy aliases (
redirect/redirect_url) as primary sources. If onlyredirect_uriwas provided, the provider's internal redirect value could be empty in some flows.Fix
The normalization is now done in the base provider so all providers benefit consistently:
redirect_uri.redirect_urlas a compatibility mirror.redirect_urias the source for$this->redirectUrl.withRedirectUrl()in sync by writing bothredirect_uriandredirect_url.Token exchange already uses base
getTokenFields(), which sends:coderedirect_uriSo after normalization,
userFromCode()token requests includeredirect_uriautomatically.Tests
Added/updated tests to prove behavior:
tests/Providers/GoogleTest.php::test_google_user_from_code_uses_redirect_uri_config_keyredirect_uri=https://example.com/callbackwhen config only hasredirect_uri.tests/OAuthTest.phpredirect_uriandredirectin auth URL generation.Docs
Updated examples in
README.mdandREADME_EN.mdto useredirect_urias the standard key, while documentingredirectandredirect_urlas legacy aliases.Validation
Executed locally:
vendor/bin/phpunit tests/Providers/GoogleTest.phpvendor/bin/phpunit tests/OAuthTest.phpvendor/bin/phpunitAll tests pass (existing suite-level warning/deprecation output remains unchanged).