Authication using acees token works for facebook but not twitter and VK
I have successfully authenticated user using direct access token in case of face-book but not for twitter and VK.
backend -> twitter , it gives me the error 401 Client Error: Unauthorized .
backend -> vk-oauth2 , it gives me the error user_data() takes at least 3 arguments (2 given) .
My function is as follows :
if backend == 'facebook': user = request.strategy.backend.do_auth(access_token) elif backend == 'twitter': user = request.strategy.backend.do_auth({'oauth_token': '...', 'oauth_token_secret': '...'}) elif backend == 'vk-oauth2': user = request.strategy.backend.do_auth(access_token)
@ranjeetsghrix, do you have a traceback for the twitter error?
@omab Here is the trace-back for twitter error : Environment:
Request Method: GET Request URL: http:///social_service/auth/twitter/
Django Version: 1.6.2 Python Version: 2.7.4 Installed Applications: ('grappelli', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ) Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.locale.LocaleMiddleware', 'config.lang.SessionBasedLocaleMiddleware')
Traceback: File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
-
File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/social/apps/django_app/utils.py" in wrapperresponse = wrapped_callback(request, _callback_args, *_callback_kwargs) -
File "/home/ghrix/projects2014/Test/test/social_services/views.py" in register_by_access_tokenreturn func(request, backend, _args, *_kwargs) -
File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/social/backends/oauth.py" in do_authuser = request.strategy.backend.do_auth({'oauth_token': '....', 'oauth_token_secret': '.....'}) -
File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/social/backends/twitter.py" in user_datadata = self.user_data(access_token) -
File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/social/backends/base.py" in get_jsonauth=self.oauth_auth(access_token) -
File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/social/backends/base.py" in requestreturn self.request(url, _args, *_kwargs).json() -
File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/requests/models.py" in raise_for_statusresponse.raise_for_status() -
raise HTTPError(http_error_msg, response=self)
Exception Type: HTTPError at /social_service/auth/twitter/ Exception Value: 401 Client Error: Unauthorized
@omab Hi any updates ??
@ranjeetsghrix, I didn't tested twitter yet, there's any chance there's an oauth_verifier parameter accessible in your register_by_access_token view (or that your client can pass to it)?
I'm closing this issue in favor of #272, check my comment https://github.com/omab/python-social-auth/issues/272#issuecomment-43428162
@omab Thanks for the reply but The issue is still remain same for me and unlike maryokhin https://github.com/omab/python-social-auth/issues/272#issuecomment-43770728 , I have defined all keys in my settings but stll doesn't work for me.
Also the issue of VK authentications is not resolved I am still getting the user_data() takes at least 3 arguments (2 given)
My code is as follows :
if backend == 'vk-oauth2':
access_token ="abcbcbbc"
user = request.strategy.backend.do_auth(access_token)
and traceback is as follows :
Environment:
Request Method: GET
Request URL: http://{domain_name}/social_service/auth/vk-oauth2/
Django Version: 1.6.2
Python Version: 2.7.3
Installed Applications:
('grappelli',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'social.apps.django_app.default',
)
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.locale.LocaleMiddleware',
'config.lang.SessionBasedLocaleMiddleware')
Traceback:
File "/home/ghrix/MEM/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ghrix/MEM/local/lib/python2.7/site-packages/social/apps/django_app/utils.py" in wrapper
45. return func(request, backend, *args, **kwargs)
File "/home/ghrix/MEM/MemNowBackEnd/social_services/views.py" in register_by_access_token
105. user = request.strategy.backend.do_auth(access_token)
File "/home/ghrix/MEM/local/lib/python2.7/site-packages/social/backends/oauth.py" in do_auth
360. data = self.user_data(access_token, *args, **kwargs)
Exception Type: TypeError at /social_service/auth/vk-oauth2/
Exception Value: user_data() takes at least 3 arguments (2 given)