我使用Google oAuth通过YoutubeAPI获取用户信息,但我不知道获取access_token
后需要做什么要检索用户ID,请任何人帮助我。
最佳答案
请参阅 Google 的 OAuth2 documentation了解如何获取有关登录用户的信息。
这基本上只是使用正确的访问 token 对 https://www.googleapis.com/oauth2/v1/userinfo
进行 GET 调用。响应中包含用户 ID。
请注意,您还需要在首次重定向到 Google 时包含正确的范围:
https://www.googleapis.com/auth/userinfo.profile
关于google-api - 使用google oauth登录后如何获取用户id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12662127/