Skip to content

Token error: Missing unauthorized token #589

@hinnocence

Description

@hinnocence

I'm new to python social auth and am using django 1.6.6 and python social auth to provide login function.

I use CustomUser to save the twitter user information and set

SOCIAL_AUTH_USER_MODEL = 'webservice.CustomUser'

It works fine when I login my website via twitter account,and I check the database,it saves the user information to both

default.user social auth Table

and

webservice.CustomUser Table

but when I deploy it with apache, I cannot login with twitter account and it stays at the login page and then returns a error

AuthFailed at /login/twitter/

Authentication failed: ('Connection aborted.', error(110, 'Connection timed out'))

Request Method: GET

Request URL: www.demodemo.com/login/twitter/?next=/ Django Version: 1.6.6

Exception Type: AuthFailed

Exception Value:

Authentication failed: ('Connection aborted.', error(110, 'Connection timed out'))

Exception Location: /usr/local/lib/python2.7/site-packages/social/backends/base.py in request, line 223

Python Executable: /usr/bin/python

Python Version: 2.7.8

I did configure the .conf file well and when I test it locally I found that though I can login with twitter account successfully when I check the "Network" in the browser I still find a request hasn't been handled properly

http://test3.com:8000/complete/twitter/?redirect_state=eGnxBZnn1l4TTk5jUlqBy0BPZCZmL9sJ&oauth_token=una3ULjfWwDByegbn4qoKsxpHRCyGDdM&oauth_verifier=6SXp7uLxj7QhD29GP7LkuQt71xKmXZ4n

status 302

When I click the link the following error is returned

actually I try to set the

MIDDLEWARE_CLASSES = (
'myapp.middleware.SocialAuthExceptionMiddleware',
)
DEBUG = False

but I can ignore the error locally but when I deploy it with apache, it still doesn't work.

Anyone know why those happened and how to solve this? Did I forget some configuration or do i need to add extra code to handle that?

AuthTokenError at /complete/twitter/

Token error: Missing unauthorized token

Request Method: GET

Request URL: http://test3.com:8000/complete/twitter/?redirect_state=XoB4wH5a6EyJYTxywGYyYgMufR4W2pX8&oauth_token=dixi6oAsfMCBUGqP4KApQHe22h5vVBLz&oauth_verifier=0KSFg7WRocPpGNR3iwODA1pAwQZ88vbn

Django Version: 1.6.6

Exception Type: AuthTokenError

Exception Value:

Token error: Missing unauthorized token

Exception Location: /usr/local/lib/python2.7/dist-packages/social/backends/oauth.py in get_unauthorized_token, line 202

Python Executable: /usr/bin/python

Python Version: 2.7.6
Environment:

Request Method: GET
Request URL: test3.com:8000/complete/twitter/?redirect_state=XoB4wH5a6EyJYTxywGYyYgMufR4W2pX8&oauth_token=dixi6oAsfMCBUGqP4KApQHe22h5vVBLz&oauth_verifier=0KSFg7WRocPpGNR3iwODA1pAwQZ88vbn

Django Version: 1.6.6
Python Version: 2.7.6
Installed Applications:
('twython',
'djcelery',
'rest_framework',
'corsheaders',
'oauth2_provider',
'webservice',
'suit',
'south',
'social.apps.django_app.default',
'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',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social.apps.django_app.middleware.SocialAuthExceptionMiddleware')

Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response

  1.                 response = wrapped_callback(request, _callback_args, *_callback_kwargs)
    
    File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  2.     response = view_func(request, _args, *_kwargs)
    
    File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py" in wrapped_view
    1.     return view_func(_args, *_kwargs)
      
      File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/utils.py" in wrapper
  3.         return func(request, backend, _args, *_kwargs)
    
    File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/views.py" in complete
  4.                    redirect_name=REDIRECT_FIELD_NAME, _args, *_kwargs)
    
    File "/usr/local/lib/python2.7/dist-packages/social/actions.py" in do_complete
  5.     user = backend.complete(user=user, _args, *_kwargs)
    
    File "/usr/local/lib/python2.7/dist-packages/social/backends/base.py" in complete
  6.     return self.auth_complete(_args, *_kwargs)
    
    File "/usr/local/lib/python2.7/dist-packages/social/backends/oauth.py" in auth_complete
  7.     token = self.get_unauthorized_token()
    
    File "/usr/local/lib/python2.7/dist-packages/social/backends/oauth.py" in get_unauthorized_token
  8.         raise AuthTokenError(self, 'Missing unauthorized token')
    

Exception Type: AuthTokenError at /complete/twitter/
Exception Value: Token error: Missing unauthorized token

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions