如何使用google oauth登录后获取用户ID [英] How to get user id after login with google oauth

查看:585
本文介绍了如何使用google oauth登录后获取用户ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google oAuth通过YoutubeAPI获取用户信息,但我不知道在获取 access_token 来检索用户ID后我需要做什么,有人请帮助我。 rel =nofollow> OAuth2文档了解如何获取登录用户的信息。



它基本上只是一个GET调用具有正确的访问令牌的https://www.googleapis.com/oauth2/v1/userinfo 。在响应中包含用户ID。



请注意,您还需要在第一次重定向到Google时包含正确的范围:

  https://www.googleapis.com/auth/userinfo.profile 


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:

https://www.googleapis.com/auth/userinfo.profile

这篇关于如何使用google oauth登录后获取用户ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆