This question already has an answer here:
- How to identify a Google OAuth2 user? 6 answers
I use Google oAuth to get user info via YoutubeAPI, but I don't know what I need to do after get access_token
to retrieve userID, anybody please help me.
This question already has an answer here:
I use Google oAuth to get user info via YoutubeAPI, but I don't know what I need to do after get access_token
to retrieve userID, anybody please help me.
See Google's OAuth2 documentation for how to get information about the logged in user.
It's basically just a GET call to
https://www.googleapis.com/oauth2/v1/userinfo
with a correct access token. In the response the user id is included.Note that you also need to include the correct scope in your very first redirect to Google:
If you're asking about how to get either the YouTube username or the YouTube user ID for the currently authenticated user, it can be found in the response to a properly authenticated request to
http://gdata.youtube.com/feeds/api/users/default?v=2
You can do one of the following:
www.googleapis.com/oauth2/v1/userinfo
id_token
that you get in the initial request, using a JWT libraryI'd recommend the latter as it is more robust and doesn't require an extra call.
See this thread for more info: How to identify a Google OAuth2 user?