'unicode' object has no attribute 'update'

490 views
Skip to first unread message

ANOOP M.S

unread,
Apr 12, 2016, 6:54:27 AM4/12/16
to python-social-auth
 Hi.. i am trying to implement python social auth for my project, so i am getting the authorization key from my android client with that i am able to get the access token and when i pass the token it saves the user data in the db without the email and username is an id, and the main problem is that when i try to login as a new user it gives me this error 'unicode' object has no attribute 'update'.  

i tries the same with the web app it saves the data properly(username, email) but wheneven i try with a new user it gives me the same error.

can any one help me please?

Joseph Vithayathil

unread,
Apr 12, 2016, 7:26:01 AM4/12/16
to python-social-auth
Hai..
   This error is occurring for me also but only............. when a registered user trys to login again with their same google account . Please some who has got something to help please contribute to this thread.

Matías Aguirre

unread,
Apr 12, 2016, 1:43:21 PM4/12/16
to Joseph Vithayathil, python-social-auth
Do you have any full traceback with this error?
--
Matías Aguirre
http://matiasaguirre.net

ANOOP M.S

unread,
Apr 12, 2016, 2:14:55 PM4/12/16
to python-social-auth, joseph...@gmail.com

yep this is the traceback.. i have created a new thread explaining what i have done.

Internal Server Error: /complete/google-oauth2/
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/apps/django_app/utils.py", line 51, in wrapper
    return func(request, backend, *args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/apps/django_app/views.py", line 28, in complete
    redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/actions.py", line 43, in do_complete
    user = backend.complete(user=user, *args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/backends/base.py", line 41, in complete
    return self.auth_complete(*args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/utils.py", line 229, in wrapper
    return func(*args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/backends/oauth.py", line 387, in auth_complete
    *args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/utils.py", line 229, in wrapper
    return func(*args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/backends/oauth.py", line 398, in do_auth
    return self.strategy.authenticate(*args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/strategies/django_strategy.py", line 96, in authenticate
    return authenticate(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py", line 74, in authenticate
    user = backend.authenticate(**credentials)
  File "/home/proja/oauth/cloudi/poc/social/backends/base.py", line 82, in authenticate
    return self.pipeline(pipeline, *args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/backends/base.py", line 85, in pipeline
    out = self.run_pipeline(pipeline, pipeline_index, *args, **kwargs)
  File "/home/proja/oauth/cloudi/poc/social/backends/base.py", line 112, in run_pipeline
    result = func(*args, **out) or {}
  File "/home/proja/oauth/cloudi/poc/social/pipeline/social_auth.py", line 88, in load_extra_data
    social.set_extra_data(extra_data)
  File "/home/proja/oauth/cloudi/poc/social/storage/django_orm.py", line 16, in set_extra_data
    if super(DjangoUserMixin, self).set_extra_data(extra_data):
  File "/home/proja/oauth/cloudi/poc/social/storage/base.py", line 85, in set_extra_data
    self.extra_data.update(extra_data)
AttributeError: 'unicode' object has no attribute 'update'
[12/Apr/2016 16:03:01] "GET /complete/google-oauth2/?state=8NlIgJo74j9JDIHpVALFXQfO2l40NZow&code=4/olMzYYqBq8Fu4-I0XmqwXnaafecKnWcwlRC1oBe0ilg&authuser=0&session_state=5a841d1d07957df4ee0c47ca5f33435db7f6002f..f400&prompt=none HTTP/1.1" 500 195815

Matías Aguirre

unread,
Apr 12, 2016, 2:30:44 PM4/12/16
to ANOOP M.S, python-social-auth, Joseph Vithayathil
That issue should be already solved
(https://github.com/omab/python-social-auth/blob/master/social/storage/base.py#L84-L89),
I'll be releasing a new version of python-social-auth later today.

ANOOP M.S

unread,
Apr 12, 2016, 2:49:03 PM4/12/16
to python-social-auth, anoo...@gmail.com, joseph...@gmail.com
Thanks Matías Aguirre , i have one more doubt why am i not getting the proper username and email id with token i am receiving from the client. i am getting the access token from the authorization token given by the client using oauth2client , is it the right way to do it?

Matías Aguirre

unread,
Apr 13, 2016, 2:03:30 PM4/13/16
to ANOOP M.S, python-social-auth, Joseph Vithayathil
I'm not entirely sure what you are talking about, what backend are you
using? Is this OAuth1 or 2? Looks like there's a mobile client
involved, how's your approach to make it work?

BTW, v0.2.16 was just released to pypi.

Thanks,
Matías

Joseph Vithayathil

unread,
Apr 14, 2016, 10:25:52 AM4/14/16
to python-social-auth
Hai...
Thank u all for the support...

Yes I am using an android mobile client, and have a issue with it like the user name saved is like a big random numeric string and the e-mail is also not getting saved.


The major issue is that when the same user with same Google account logins in the web side and Android client side both are saved as different users django user model's.

Please help with the proper method to approach this issue.

Matías Aguirre

unread,
Apr 14, 2016, 10:44:22 AM4/14/16
to Joseph Vithayathil, python-social-auth
Could you detail how's it working? How's the android client calling
your app? What does it send? What code handles that call?

ANOOP M.S

unread,
Apr 14, 2016, 11:43:21 AM4/14/16
to Matías Aguirre, python-social-auth, Joseph Vithayathil

Hi martìas..
I think me and joseph have the same problem, my project is a unity game . i am using an official Google sign in module for unity it asks the permissions there and sending me an authorization key, so i am using oauth2client to get the access key, which then I sends to python-social-auth, but I am not getting the mail id  and username, so if try login in from website it will be a different user.

I am yet to try the new update

Joseph Vithayathil

unread,
Apr 14, 2016, 1:22:37 PM4/14/16
to python-social-auth
Hai Matías and Anoop

Thank u for all your support, this gives a positive approach to the work. As I am a newbee to this scenario it is very encouraging for me to get advise from senior personls and help work better by enjoying it ...

I am sending the code that is written below please check it and suggest for the reqired changes needed for the code to work properly or, if I am totally wrong please guide me to the right path guys...


Also I am planing to go ahead with the django rest frame work so please take this also in mind when u r making a response. It is all easy to have RESTFull communication that are done with the client.


Code.....................


#Views.py

import os
from oauth2client import client#flow_from_clientsecrets
CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), '..', 'client_secrets.json')

flow = client.flow_from_clientsecrets(
CLIENT_SECRETS,
scope=['https://www.googleapis.com/auth/games','profile','email'],
redirect_uri='http://localhost:8080/oauth2callback')

from social.apps.django_app.utils import psa
from social.apps.django_app.default.models import UserSocialAuth

#URL = /login_socialauth/google-oauth2/
@csrf_exempt
@psa('social:complete')
def register_by_access_token(request, backend):
#Inside this get function we get the id-token form client provided by the google
#to the client to uniquely identify the user and application

#We also get the backend as google-oath2 , facebook ,....etc for google and facebook respectively

#Rest is done by the social oauth

#ID-Token is used to get the extra information about the user like the refresh ,access token ,
#expiry of the access token etc..
credentials = flow.step2_exchange(request.GET['id_token'])
credentials.revoke(httplib2.Http())
print "id_token:",json.dumps(credentials.id_token)

#We can get the access token and refresh token from the credentials
#using credentials.access_token and credentials.refresh_token respectively

# http_auth = credentials.authorize(httplib2.Http())


#Access token that is rec
user = request.backend.do_auth(credentials.access_token)
print request.user
response_data = {}
response_data['Status'] = 'OK'
response_data['Response'] = True
response_data['Message'] = "SUCCESS"
return HttpResponse(json.dumps(response_data),content_type="application/json")
Reply all
Reply to author
Forward
Message has been deleted
0 new messages