I am getting the following error:
Environment:
Request Method: GET
Request URL: http://localhost/api/social/complete/yahoo-oauth/?oauth_token=qgf9qgm&oauth_verifier=xqmcyd
Django Version: 1.6
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'corsheaders',
'yahoo_app')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'corsheaders.middleware.CorsMiddleware',
'middleware.crossdomainxhr.XsSharing')
Traceback:
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
-
response = wrapped_callback(request, _callback_args, *_callback_kwargs)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
-
return view_func(_args, *_kwargs)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/apps/django_app/utils.py" in wrapper
-
return func(request, backend, _args, *_kwargs)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/apps/django_app/views.py" in complete
-
redirect_name=REDIRECT_FIELD_NAME, _args, *_kwargs)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/actions.py" in do_complete
-
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/strategies/base.py" in complete
-
return self.backend.auth_complete(_args, *_kwargs)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/backends/oauth.py" in auth_complete
-
return self.do_auth(access_token, _args, *_kwargs)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/backends/oauth.py" in do_auth
-
return self.strategy.authenticate(_args, *_kwargs)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/strategies/django_strategy.py" in authenticate
-
return authenticate(_args, *_kwargs)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/django/contrib/auth/init.py" in authenticate
-
user = backend.authenticate(**credentials)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/backends/base.py" in authenticate
-
return self.pipeline(pipeline, _args, *_kwargs)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/backends/base.py" in pipeline
-
out = self.run_pipeline(pipeline, pipeline_index, _args, *_kwargs)
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/backends/base.py" in run_pipeline
-
result = func(_args, *_out) or {}
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/pipeline/social_auth.py" in social_details
-
return {'details': strategy.backend.get_user_details(response)}
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/social/backends/yahoo.py" in get_user_details
-
email = response.get('emails')[0]['handle']
Exception Type: KeyError at /social/complete/yahoo-oauth/
Exception Value: 'handle'
Above error comes because the response from yahoo contains a list with emails like the following:
response
{'access_token': {u'oauth_authorization_expires_in': u'_667',
u'oauth_expires_in': u'3600',
u'oauth_session_handle': u'__',
u'oauth_token': u'__',
u'oauth_token_secret': u'*_39b',
u'xoauth_yahoo_guid': u'_6GM'},
u'created': u'2010-01-22T08:24:16Z',
u'emails': [{u'id': 1, u'type': u'HOME'},
{u'handle': u'__ter@yahoo.com',
u'id': 2,
u'primary': True,
u'type': u'HOME'},
{u'id': 7, u'type': u'HOME'}],
u'familyName': u'_****',
...}
I suggest iterate over the list of emails and check which element contains the handle key.
I am getting the following error:
Environment:
Request Method: GET
Request URL: http://localhost/api/social/complete/yahoo-oauth/?oauth_token=qgf9qgm&oauth_verifier=xqmcyd
Django Version: 1.6
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'corsheaders',
'yahoo_app')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
'corsheaders.middleware.CorsMiddleware',
'middleware.crossdomainxhr.XsSharing')
Traceback:
File "/home/lladmin/hanu_api/shared/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
Exception Type: KeyError at /social/complete/yahoo-oauth/
Exception Value: 'handle'
Above error comes because the response from yahoo contains a list with emails like the following:
response
{'access_token': {u'oauth_authorization_expires_in': u'_667',
u'oauth_expires_in': u'3600',
u'oauth_session_handle': u'__',
u'oauth_token': u'__',
u'oauth_token_secret': u'*_39b',
u'xoauth_yahoo_guid': u'_6GM'},
u'created': u'2010-01-22T08:24:16Z',
u'emails': [{u'id': 1, u'type': u'HOME'},
{u'handle': u'__ter@yahoo.com',
u'id': 2,
u'primary': True,
u'type': u'HOME'},
{u'id': 7, u'type': u'HOME'}],
u'familyName': u'_****',
...}
I suggest iterate over the list of emails and check which element contains the handle key.