Add support for OAuth 2.0 authorization code flow without requiring a custom button.#78
Open
astarrh wants to merge 99 commits into
Open
Add support for OAuth 2.0 authorization code flow without requiring a custom button.#78astarrh wants to merge 99 commits into
astarrh wants to merge 99 commits into
Conversation
Modified utils.ts to allow dynamically passing custom scopes via options. Updated types.ts to reflect changes in the type definitions.
- Introduced the `authMode` prop to allow switching between "credential" and "code" flows. - Render GIS-styled buttons for consistent styling in both flows. - Added logic to override GIS default behavior when `authMode` is set to "code". - Ensured compatibility with OAuth 2.0 authorization code flow by using `google.accounts.oauth2.initCodeClient`. - Improved flexibility for developers needing custom authentication/authorization logic.
devbaji
reviewed
Aug 3, 2025
devbaji
left a comment
Owner
There was a problem hiding this comment.
Can you look into the changes? I can see 43 file changes. Is this correct?
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.
This PR introduces an authMode prop to enable support for the OAuth 2.0 authorization code flow in the GoogleLogin component in addition to the existing credential-based flow. This is accomplished by using the GIS button style and replacing the click listener with logic from
google.accounts.oauth2.initCodeClient.:if (button) { window.google.accounts.id.renderButton(button, buttonConfig); const newButton = button.cloneNode(true); button.parentNode!.replaceChild(newButton, button); newButton.addEventListener("click", () => { oauthClient.requestCode(); // Custom behavior }); }Default behavior remains unchanged, but developers may toggle the new behavior with the authMode prop:
Default behavior may be set explicitly with
authMode="'credential'". This module doesn't contain a testing package, but on my system it is working as expected and is backwards compatible.Key Changes in the PR:
1. Added authMode: "code" to support google.accounts.oauth2.initCodeClient.
2. Updated the GoogleLogin component to dynamically render buttons based on the selected flow.
3. Ensured backward compatibility with existing credential behavior.
4. Added documentation and examples for the new authMode prop.
Closes #71