来自 Google OAuth API 的姓名、电子邮件
我想允许用户在网站上使用 google 登录并收集他们的姓名和电子邮件地址,但我找不到有关 google api 的 userinfo 范围的任何文档: https://www.googleapis.com/auth/userinfo。
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是获取姓名和电子邮件的更好方法。
将范围设置为:
https://www.googleapis.com/auth/userinfo.email
和
https://www.googleapis.com/auth/userinfo.profile
并使用端点:
https://www.googleapis.com/oauth2/v1/userinfo?alt=json
这将为您提供所需的一切!
This is a better way to get the name and email.
Set your scopes to:
https://www.googleapis.com/auth/userinfo.email
and
https://www.googleapis.com/auth/userinfo.profile
And use the endpoint:
https://www.googleapis.com/oauth2/v1/userinfo?alt=json
That will get you all you need!
我用
http://www-opensocial.googleusercontent.com/api/people/ 和 https://www.googleapis.com/auth/userinfo#email 作为请求令牌的范围。
受保护的资源url是
https://www-opensocial.googleusercontent.com/api/people/@me/@self< /a> 获取当前用户的数据。
我获取了用户的 G+ 个人资料和姓名。我还无法收到用户的电子邮件,但我想我已经接近了
I use
http://www-opensocial.googleusercontent.com/api/people/ and https://www.googleapis.com/auth/userinfo#email as the scope of the request tokens.
The protected resource url is
https://www-opensocial.googleusercontent.com/api/people/@me/@self to get the current user's data.
I get the user's G+ profile and name. I'm not able yet to get the user's email but I think i'm close
使用 Google Python API 检索 OAuth 用户信息:
https://developers.google。 com/api-client-library/python/start/installation
https://developers.google.com/api-client-library/python /guide/aaa_oauth
Retrieve OAuth userinfo using the Google Python API:
https://developers.google.com/api-client-library/python/start/installation
https://developers.google.com/api-client-library/python/guide/aaa_oauth
一个客户端JavaScript SDK,用于使用OAuth2(和OAuth1)使用OAuth代理)Web Services进行认证,并查询其REST API。 HelloJS标准化了对普通API的路径和响应,例如Google Data Services,Facebook Graph和Windows Live Connect。它的模块化使该清单正在增长。不再使用意大利面条代码!
http://adodson.com/hello.js/
A client-side Javascript SDK for authenticating with OAuth2 (and OAuth1 with a oauth proxy) web services and querying their REST API's. HelloJS Standardizes paths and responses to common API's like Google Data Services, Facebook Graph and Windows Live Connect. Its modular so that list is growing. No more spaghetti code!
http://adodson.com/hello.js/
借助最新的OAuth 2草案支持,Google提供Google ID令牌,这是一个开放式连接实现,如果您包括范围 https://www.googleapis.com/auth/userinfo.profile 和 - 将提供电子邮件地址(在最新的Java API中,请参见类
GoogleIdtoken
)。不幸的是,这并不能提供用户的名称。但这是一种需要更少的往返方式的方式,如果您只能使用电子邮件地址进行。With the latest OAuth 2 draft support, Google provides Google ID tokens, an OpenID Connect implementation which - if you include the scopes https://www.googleapis.com/auth/userinfo.profile and https://www.googleapis.com/auth/userinfo.email - will supply the email address (see the class
GoogleIdToken
in the latest Java API). Unfortunately, though, this doesn't provide the user's name. But it is a way that requires fewer roundtrips, if you can make do with just the email address.这是一个使用 Google 代码如何获取用户详细信息的 php 示例
....
$oauth2Service = new Google_Oauth2Service($client);
var_dump($oauth2Service->userinfo->get());
...
贝娄是来自谷歌的课程
http://code .google.com/p/google-api-php-client/source/browse/trunk/src/contrib/Google_Oauth2Service.php
Here is a php example using Google code how to get users details
....
$oauth2Service = new Google_Oauth2Service($client);
var_dump($oauth2Service->userinfo->get());
...
Bellow is the class from google
http://code.google.com/p/google-api-php-client/source/browse/trunk/src/contrib/Google_Oauth2Service.php