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
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
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!
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
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()
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!
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.
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