python-social-auth icon indicating copy to clipboard operation
python-social-auth copied to clipboard

Authication using acees token works for facebook but not twitter and VK

Open ranjeetsghrix opened this issue 12 years ago • 6 comments

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 avatar Apr 02 '14 09:04 ranjeetsghrix

@ranjeetsghrix, do you have a traceback for the twitter error?

omab avatar Apr 02 '14 16:04 omab

@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

  1.                 response = wrapped_callback(request, _callback_args, *_callback_kwargs)
    
    File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/social/apps/django_app/utils.py" in wrapper
  2.         return func(request, backend, _args, *_kwargs)
    
    File "/home/ghrix/projects2014/Test/test/social_services/views.py" in register_by_access_token
  3.     user = request.strategy.backend.do_auth({'oauth_token': '....', 'oauth_token_secret':  '.....'})
    
    File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/social/backends/oauth.py" in do_auth
  4.     data = self.user_data(access_token)
    
    File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/social/backends/twitter.py" in user_data
  5.         auth=self.oauth_auth(access_token)
    
    File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/social/backends/base.py" in get_json
  6.     return self.request(url, _args, *_kwargs).json()
    
    File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/social/backends/base.py" in request
  7.     response.raise_for_status()
    
    File "/home/ghrix/projects2014/test/local/lib/python2.7/site-packages/requests/models.py" in raise_for_status
  8.         raise HTTPError(http_error_msg, response=self)
    

Exception Type: HTTPError at /social_service/auth/twitter/ Exception Value: 401 Client Error: Unauthorized

ranjeetsghrix avatar Apr 03 '14 03:04 ranjeetsghrix

@omab Hi any updates ??

ranjeetsghrix avatar Apr 03 '14 06:04 ranjeetsghrix

@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)?

omab avatar Apr 03 '14 17:04 omab

I'm closing this issue in favor of #272, check my comment https://github.com/omab/python-social-auth/issues/272#issuecomment-43428162

omab avatar May 18 '14 00:05 omab

@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)

ranjeetsghrix avatar May 28 '14 05:05 ranjeetsghrix