Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get User Info (Email ID) while using the Authorization Code Flow #866

Open
Yashs911 opened this issue Jun 9, 2023 · 2 comments
Open

Comments

@Yashs911
Copy link

Yashs911 commented Jun 9, 2023

Important gapi.auth2 notice: gapi.auth2 has been deprecated and replaced with Google Identity Services. Please see https://developers.google.com/identity/sign-in/web/deprecation-and-sunset for more information. If you have questions related to authentication/authorization please look at the associated documentation or post questions on Stack Overflow with the google-oauth tag.

Summary
I have migrated to the GIS but unable to understand how to get the User Profile Info without using the Auth Code. So I use the Authorization Code Flow which returns the Auth Code, which I send back to the backend. But I also require the user email id to map the same. But I am unable to find any documentation which solves this problem.

To get user profile information one needs to use the Auth Code and generate the access_token and refresh_token and use the same to call People's API. But then the Auth Code cannot be used by the backend.

Currently I am using an input field to get the user email id but it's causes issues due to typos.

function initClient() {
client = google.accounts.oauth2.initCodeClient({
client_id: CLIENT_ID,
scope: SCOPES,
ux_mode: 'popup',
callback: async (response) => {
auth_code = response.code;
// Logic to send the Auth Code to the backend with user email ID
}
});
}

@hermz365
Copy link

To obtain user profile information, you should use Sign in with Google library to obtain a JWT ID Token. You can use the Sign in with Google button and/or One Tap to authenticate your users and obtain the JWT ID Token.

@masa8
Copy link

masa8 commented Sep 27, 2023

I want to know this too.
I added an API on the backend for the client to get the information needed for now.
but I don't know if this is common and if there are any security risks.
This question is more about Authorization code flow than about this library though... 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants