来自 Google OAuth API 的姓名、电子邮件

发布于 2024-12-04 17:39:47 字数 209 浏览 1 评论 0 原文

我想允许用户在网站上使用 google 登录并收集他们的姓名和电子邮件地址,但我找不到有关 google api 的 userinfo 范围的任何文档: https://www.googleapis.com/auth/userinfo

谢谢

I want to allow users to login with google on a site and collect their name and email address but I can't find any documentation on the userinfo scope for google's api: https://www.googleapis.com/auth/userinfo.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

七七 2024-12-11 17:39:47

这是获取姓名和电子邮件的更好方法。

将范围设置为:

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!

小女人ら 2024-12-11 17:39:47

我用
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

听风念你 2024-12-11 17:39:47

使用 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

import httplib2
from apiclient.discovery import build
from oauth2client.client import OAuth2WebServerFlow

http = httplib2.Http()
http = credentials.authorize(http)

users_service = build('oauth2', 'v2', http=http)
user_document = users_service.userinfo().get().execute()

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

import httplib2
from apiclient.discovery import build
from oauth2client.client import OAuth2WebServerFlow

http = httplib2.Http()
http = credentials.authorize(http)

users_service = build('oauth2', 'v2', http=http)
user_document = users_service.userinfo().get().execute()
〃安静 2024-12-11 17:39:47

一个客户端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/

美男兮 2024-12-11 17:39:47

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.

§普罗旺斯的薰衣草 2024-12-11 17:39:47

这是一个使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文