Retrieving user email address after Google AuthSub authentication

How can I obtain user account details after successful Google AuthSub authentication?

I’m working with Google’s AuthSub authentication system and running into an issue. After a user successfully authenticates, I receive an access token for the specified service scope. However, I can’t figure out how to retrieve basic user information like their email address.

The authentication flow works fine and I get the token, but I need to know which Google service or API endpoint allows me to fetch the authenticated user’s Gmail address or other profile data.

What’s the proper way to get this information once authentication is complete?

In order to retrieve user account details after Google AuthSub authentication, ensure you have requested the correct OAuth 2.0 scopes during your authentication process, specifically ‘email’ and ‘profile’. After receiving the access token, use the Google People API, particularly the user info endpoint, to obtain the user’s email address. If you have included the necessary scopes in your request, you should be able to access the profile data seamlessly. This practice helps avoid permission issues down the line.

To retrieve the user’s email address after a successful Google AuthSub authentication, make a GET request to https://www.googleapis.com/oauth2/v1/userinfo, including your access token in the Authorization header. This will provide basic profile information, including the email address. Ensure that you requested the appropriate scopes during authentication; otherwise, the API call will fail despite having a valid token. Personally, I find this method more straightforward than using the People API when you only need basic profile data.

authsub’s old news, but if ya gotta use it, check the userinfo endpoint at https://www.googleapis.com/oauth2/v2/userinfo with your token. just remember to ask for email scope or you’ll get only the basics.