[get username, email address]

165 views
Skip to first unread message

rahulkave

unread,
Sep 1, 2012, 2:34:49 PM9/1/12
to django-so...@googlegroups.com
Hi,
I have an app of feedback portal system, I integrated djago-social-auth, and its working fine, now my requirement is, how sould I get the username of the person using google-oauth2 gives feedback.

Regards
rahulkave
bartender,redwine.sdrclabs

Matías Aguirre

unread,
Sep 2, 2012, 2:15:16 PM9/2/12
to django-social-auth
What do you mean with username? Google doesn't has usernames, it uses email
addresses to denote a user, here's the usual response from google-oauth2
service:

{
u'family_name': u'Aguirre',
u'name': u'Mat\xedas Aguirre',
u'picture': u'https://lh5.googleusercontent.com/-ui-GqpNh5Ms/AAAAAAAAAAI/AAAAAAAAAOw/_PsQmVgLN24/photo.jpg',
u'access_token': u'XXX',
u'id_token': u'XXX',
u'expires_in': 3599,
u'id': u'101232039528694454898',
u'token_type': u'Bearer',
u'locale': u'en',
u'birthday': u'0000-08-10',
u'link': u'https://plus.google.com/101232039528694454895',
u'given_name': u'Mat\xedas',
u'gender': u'male',
u'email': u'matias...@gmail.com',
u'verified_email': True
}

Excerpts from rahulkave's message of 2012-09-01 15:34:49 -0300:
--
Matías Aguirre (matias...@gmail.com)

rahulkave

unread,
Sep 3, 2012, 9:57:23 AM9/3/12
to django-so...@googlegroups.com
Thanks for the replying.
I agree that Google uses email addresses.
but how to get these details ??

On Sunday, September 2, 2012 11:46:04 PM UTC+5:30, Matías Aguirre wrote:
What do you mean with username? Google doesn't has usernames, it uses email
addresses to denote a user, here's the usual response from google-oauth2
service:

    {
        u'family_name': u'Aguirre',
        u'name': u'Mat\xedas Aguirre',
        u'picture': u'https://lh5.googleusercontent.com/-ui-GqpNh5Ms/AAAAAAAAAAI/AAAAAAAAAOw/_PsQmVgLN24/photo.jpg',
        u'access_token': u'XXX',
        u'id_token': u'XXX',
        u'expires_in': 3599,
        u'id': u'101232039528694454898',
        u'token_type': u'Bearer',
        u'locale': u'en',
        u'birthday': u'0000-08-10',
        u'link': u'https://plus.google.com/101232039528694454895',
        u'given_name': u'Mat\xedas',
        u'gender': u'male',
        u'email': u'matia...@gmail.com',

Matías Aguirre

unread,
Sep 3, 2012, 10:24:09 AM9/3/12
to rahulkave, django-social-auth
Those are the default values in the "response" attribute that any pipeline
entry receives, you could add a custom entry to the pipeline to store them on
some place or just define this setting with the needed values you want to
store:

GOOGLE_OAUTH2_EXTRA_DATA = (
('picture', 'picture'),
('link, 'gplus_link'),
...
)

The values will be stored in extra_data attribute in the related UserSocialAuth
instance. The first name in the tuples are the key name in the dict I've sent
before, the second is the name that will be used to be stored in extra_data
attribute.

To access this values do:

user.social_auth.get(provider='google-oauth2').extra_data['picture']

Hope this helps,
Matías

Excerpts from rahulkave's message of 2012-09-03 10:57:23 -0300:
> Thanks for the replying.
> I agree that Google uses email addresses.
> but how to get these details ??
>
> On Sunday, September 2, 2012 11:46:04 PM UTC+5:30, Matías Aguirre wrote:
> >
> > What do you mean with username? Google doesn't has usernames, it uses
> > email
> > addresses to denote a user, here's the usual response from google-oauth2
> > service:
> >
> > {
> > u'family_name': u'Aguirre',
> > u'name': u'Mat\xedas Aguirre',
> > u'picture': u'
> > https://lh5.googleusercontent.com/-ui-GqpNh5Ms/AAAAAAAAAAI/AAAAAAAAAOw/_PsQmVgLN24/photo.jpg',
> >
> > u'access_token': u'XXX',
> > u'id_token': u'XXX',
> > u'expires_in': 3599,
> > u'id': u'101232039528694454898',
> > u'token_type': u'Bearer',
> > u'locale': u'en',
> > u'birthday': u'0000-08-10',
> > u'link': u'https://plus.google.com/101232039528694454895',
> > u'given_name': u'Mat\xedas',
> > u'gender': u'male',
> > u'email': u'matia...@gmail.com <javascript:>',
> > u'verified_email': True
> > }
> >
> > Excerpts from rahulkave's message of 2012-09-01 15:34:49 -0300:
> > > Hi,
> > > I have an app of feedback portal system, I integrated djago-social-auth,
> > > and its working fine, now my requirement is, how sould I get the
> > username
> > > of the person using google-oauth2 gives feedback.
> > >
> > > Regards
> > > rahulkave
> > > bartender,redwine.sdrclabs
> > --
> > Matías Aguirre (matias...@gmail.com <javascript:>)
> >
--
Matías Aguirre (matias...@gmail.com)
Reply all
Reply to author
Forward
0 new messages