Comments (9)
Hi,
I think there's not service google service to get such information. Let me know if you find anything.
Thanks
from django-social-auth.
I found a way https://www-opensocial.googleusercontent.com/api/people
Here is an example:
token = 'O AUTH TOKEN'
scope = "https://www-opensocial.googleusercontent.com/api/people"
url = "%s/@me/@self" % scope
params='OAuth %s' % token
request = Request(url, headers={'Authorization': params})
data = simplejson.loads(urlopen(request).read())['entry']
first_name = data['name']['givenName']
last_name = data['name']['familyName']
I use this with Celery to download info plus avatar.
from django-social-auth.
Interesting, I'll take a look and add this to google auth methods.
Thanks!
from django-social-auth.
I want to implement this feature, but can't find any documentation about this API on Google Code.
Could anybody point me at it?
from django-social-auth.
I've tried working with that one too without luck :-/
from django-social-auth.
According to this discussion on Google Groups, Googlers are still working to implement appropriate API. Hope they do that at last.
from django-social-auth.
I think the scope should be https://www.googleapis.com/auth/userinfo.profile. Here is an example application with source.
from django-social-auth.
Just write this google oauth2 backend to get the full profile !
May be integrated in 'google-oauth2' backend ?
googlebackend.py:
from urllib import urlencode
from urllib2 import Request, urlopen
from django.utils import simplejson
from social_auth.backends import USERNAME
from social_auth.backends.google import GoogleOAuth2, GoogleOAuth2Backend, BACKENDS
import settings
class GoogleProfileBackend(GoogleOAuth2Backend):
"""Google OAuth2 authentication backend"""
name = 'google-profile'
def get_user_details(self, response):
"""Return user details from Google account"""
email = response['email']
return {USERNAME: email.split('@', 1)[0],
'email': email,
'fullname': response.get('name',''),
'first_name': response.get('given_name',''),
'last_name': response.get('family_name',''),
'gender': response.get('gender','')}
class GoogleProfile(GoogleOAuth2):
"""Google OAuth2 support"""
AUTH_BACKEND = GoogleProfileBackend
def get_scope(self):
return ['https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile'] + \
getattr(settings, 'GOOGLE_OAUTH_EXTRA_SCOPE', [])
def user_data(self, access_token):
"""Return user data from Google API"""
return self.googleapis_profile('https://www.googleapis.com/oauth2/v1/userinfo', access_token)
def googleapis_profile(self, url, access_token):
"""Loads user data from googleapis service
Google OAuth documentation at:
http://code.google.com/apis/accounts/docs/OAuth2Login.html
"""
data = {'access_token': access_token, 'alt': 'json'}
request = Request(url + '?' + urlencode(data))
try:
return simplejson.loads(urlopen(request).read())
except (ValueError, KeyError, IOError):
return None
BACKENDS['google-profile'] = GoogleProfile
in settings.py:
add 'yourapp.googlebackend.GoogleProfileBackend'
in the AUTHENTICATION_BACKENDS
and
SOCIAL_AUTH_IMPORT_BACKENDS = (
'yourapp',
)
expect was usfull...
from django-social-auth.
Issue fixed by pull request #284.
from django-social-auth.
Related Issues (20)
- Facebook: Authentication process canceled
- link to documentation does not work HOT 1
- 401 Client Error: Unauthorized for url: https://oauth.vk.com/access_token HOT 4
- KeyError at /complete/facebook/ ---- 'access_token' HOT 5
- Read The Docs 404 HOT 2
- Cannot resolve keyword 'response' into field. Choices are:
- Documentation link is broken HOT 1
- LinkedIn v2 update
- Manual Create User with access Token HOT 1
- Link to documentation is broken HOT 4
- Disable firstname, lastname field
- Documentation link leads to ReadTheDocs template
- social_core.exceptions.AuthFailed: Authentication failed: SAML login failed: ['invalid_response'] HOT 1
- Token POST request hangs with ASGI
- create_user is not getting called HOT 1
- pyhton3 to python
- It is not compatible in Django version 4 or later
- What about Azure AD?
- linkedin complete login step is stuck
- Is it possible to support two different Google Auth app ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-social-auth.