Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with login. #37

Closed
PaulGregor opened this issue Dec 9, 2014 · 9 comments
Closed

Problem with login. #37

PaulGregor opened this issue Dec 9, 2014 · 9 comments

Comments

@PaulGregor
Copy link

I'm trying using http://127.0.0.1:8000/rest-auth/login/ to login myself into the system but error always showes up.

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/rest-auth/login/

Django Version: 1.7.1
Python Version: 2.7.8
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'reminder',
 'rest_framework',
 'rest_framework.authtoken',
 'rest_auth',
 'allauth',
 'allauth.account',
 'rest_auth.registration',
 'allauth.socialaccount',
 'allauth.socialaccount.providers.facebook')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "I:\www\bvenv\lib\site-packages\django\core\handlers\base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "I:\www\bvenv\lib\site-packages\django\views\decorators\csrf.py" in wrapped_view
  57.         return view_func(*args, **kwargs)
File "I:\www\bvenv\lib\site-packages\django\views\generic\base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)
File "I:\www\bvenv\lib\site-packages\rest_framework\views.py" in dispatch
  406.             response = self.handle_exception(exc)
File "I:\www\bvenv\lib\site-packages\rest_framework\views.py" in dispatch
  403.             response = handler(request, *args, **kwargs)
File "I:\www\bvenv\lib\site-packages\rest_auth\views.py" in post
  52.         self.login()
File "I:\www\bvenv\lib\site-packages\rest_auth\views.py" in login
  34.         self.user = self.serializer.object['user']

Exception Type: AttributeError at /rest-auth/login/
Exception Value: 'LoginSerializer' object has no attribute 'object'

This error 'LoginSerializer' object has no attribute 'object' also is in Demo.

@jmb
Copy link
Contributor

jmb commented Dec 9, 2014

In my demo version this works fine - in settings.py I have added these lines:

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.TokenAuthentication',
   )  
}

I think you may just need the TokenAuthentication, as in rest_auth/serializers.py the LoginSerializer is defined by extending AuthTokenSerializer.

@PaulGregor
Copy link
Author

Thanks @jmb . But error still presents. I have a clean demo(or with your modifications), and if login credentials are correct I receive this error. 'LoginSerializer' object has no attribute 'object'

@jmb
Copy link
Contributor

jmb commented Dec 9, 2014

I just tried the clean demo from the master branch and (apart from adding the rest_verify_email fix so I can verify my test user's email) it works fine for me - even without the settings entries, I get back a key/token. Weird.

HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: POST, OPTIONS

{
    "key": "90aa22277c5f61b1c85905745e465633f19c0309"
}

@PaulGregor
Copy link
Author

I will try another computer and OS, maybe there I'll find luck =)

@mariposa8
Copy link

I had the same issue. And the answer I found (after 2 hours of angriness =)) in "install_requires", here >>> 'djangorestframework>=2.3.13, <3.0'. It means: don't use 3+ version of Django REST Framework. You are welcome! =)

@PaulGregor
Copy link
Author

@mariposa8 thank you so much, using djangorestframework <3.0 helped.

@papasax
Copy link

papasax commented Dec 14, 2014

thank you so much, using djangorestframework <3.0 helped.

@ConorMcGee
Copy link

Anyone have any idea what's causing this in 3.0?

@ConorMcGee
Copy link

Made this fix myself, seems to be working fine but I need to do more testing.
https://github.com/mcgeeco/django-rest-auth/compare/Tivix:master...master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants