Git Product home page Git Product logo

tivix / django-rest-auth Goto Github PK

View Code? Open in Web Editor NEW
2.4K 96.0 660.0 490 KB

This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)

Home Page: www.tivix.com

License: MIT License

Python 100.00%
authentication rest social-login django django-rest-framework

django-rest-auth's People

Contributors

akay7 avatar caruccio avatar citizen-stig avatar dgilge avatar entequak avatar fergyfresh avatar gbezyuk avatar illagrenan avatar iraycd avatar jasinai avatar jgr3go avatar jmb avatar joaoricardo000 avatar maciej-jaworski avatar mariodev avatar marsam avatar mateusz-sikora avatar maxim-kht avatar mdentremont avatar michael-k avatar mjaworski avatar mpuhacz avatar n1207n avatar philippeluickx avatar ron8mcr avatar rpatterson avatar sloria avatar tevinjoseph avatar toracle avatar vsevolod-kolchinsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-rest-auth's Issues

Demo exceptions

Hello! Just made a fresh install from master branch and came across several exceptions:

http://localhost:8000/email-verification/

NoReverseMatch at /email-verification/
Reverse for 'verify_email' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Request Method: GET
Request URL:    http://localhost:8000/email-verification/
Django Version: 1.7.1
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'verify_email' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

Also during sign up process:

NoReverseMatch at /rest-auth/registration/
Reverse for 'account_email_verification_sent' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

deleted a user

OperationalError at /admin/auth/user/3/delete/
no such table: allauth_socialaccount
Request Method: GET
Request URL: http://127.0.0.1:8888/admin/auth/user/3/delete/
Django Version: 1.8
Exception Type: OperationalError
Exception Value:
no such table: allauth_socialaccount
Exception Location: /home/coco/project/env/jifen/lib/python3.4/site-packages/Django-1.8-py3.4.egg/django/db/backends/sqlite3/base.py in execute, line 318
Python Executable: /home/coco/project/env/jifen/bin/python
Python Version: 3.4.0
Python Path:
['/home/coco/project/django-rest-auth/demo',
'/home/coco/project/env/jifen/lib/python3.4/site-packages/Django-1.8-py3.4.egg',
'/home/coco/project/env/jifen/lib/python3.4',
'/home/coco/project/env/jifen/lib/python3.4/plat-x86_64-linux-gnu',
'/home/coco/project/env/jifen/lib/python3.4/lib-dynload',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/home/coco/project/env/jifen/lib/python3.4/site-packages']
Server time: Mon, 13 Apr 2015 06:14:38 +0000

KeyError on invalid access tokens for Social Authentication ( Google and LinkedIn)

I tried to implement REST based social authentication for Google and LinkedIn (Oauth2) like the Facebook example shown in the documentation.

It works fine for valid access tokens but on entering invalid access tokens, it raises a KeyError for 'id' rather than the neat 400 BAD REQUEST response on invalid tokens for the Facebook example.

Update profile not working

I'm testing out my current django install with the sample angular app, and updating a profile is failing. The server response is {"detail":"Method 'POST' not allowed.","status":405}. Angular is printing this error to the javascript console POST http://127.0.0.1:8000/rest-auth/user/ 405 (METHOD NOT ALLOWED).

TwitterOAuth Adapter error

Got this error when trying to login with Twitter: 'TwitterOAuthAdapter' object has no attribute 'parse_token'

Allow /auth/user/ without UserProfile

Hi

I don't need an extra userprofile, just a single api-call that tells me whether a user is currently logged in or not. /auth/user/ fails in 2.2 on django 1.6 without a configured AUTH_PROFILE_MODULE with the following error message:

SiteProfileNotAvailable at /api/auth/user/
You need to set AUTH_PROFILE_MODULE in your project settings

Regards, Peter

TemplateResponseMixin error when loading pages.

Whenever I try and load a page I receive the following error:

Internal Server Error: /rest-auth/registration/account-email-verification-sent/
Traceback (most recent call last):
File "/Users/chrisfranklin/ng/coderdash/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = wrapped_callback(request, _callback_args, *_callback_kwargs)
File "/Users/chrisfranklin/ng/coderdash/env/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
return self.dispatch(request, _args, *_kwargs)
File "/Users/chrisfranklin/ng/coderdash/env/lib/python2.7/site-packages/django/views/generic/base.py", line 87, in dispatch
return handler(request, _args, *_kwargs)
File "/Users/chrisfranklin/ng/coderdash/env/lib/python2.7/site-packages/django/views/generic/base.py", line 155, in get
return self.render_to_response(context)
File "/Users/chrisfranklin/ng/coderdash/env/lib/python2.7/site-packages/django/views/generic/base.py", line 130, in render_to_response
template=self.get_template_names(),
File "/Users/chrisfranklin/ng/coderdash/env/lib/python2.7/site-packages/django/views/generic/base.py", line 142, in get_template_names
"TemplateResponseMixin requires either a definition of "
ImproperlyConfigured: TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'
[26/Oct/2014 13:48:13] "GET /rest-auth/registration/account-email-verification-sent/ HTTP/1.1" 500 111497

Any ideas what might be causing it?

can't use localhost:8000/rest-auth/registration/ to add new user.

Using angular-django-registration-auth from "python manage.py runserver" (not gunicorn) I am able to utilize the /login/ api url "http://localhost:8000/rest-auth/login/". But when I attempt to use the /registration/ api url "http://localhost:8000/rest-auth/registration/", I get HTTP 405 METHOD NOT ALLOWED, and a form showing only "Content:" and a textbox.

This is a new installation. Here is my "requirements.txt" content:

Django==1.7.6
dj-database-url==0.3.0
dj-static==0.0.6
django-appconf==1.0.1
djangorestframework==3.0.5
django-rest-auth==0.3.4
django-allauth==0.19.1
drf-nested-routers==0.9.0
drf-extensions
gunicorn==19.1.1
six==1.9.0
static3==0.5.1
wsgiref==0.1.2

I believe I have correctly followed the instructions in "http://django-rest-auth.readthedocs.org/en/latest/installation.html#registration-optional" for INSTALLED_APPS , and myapp/urls.py.

Here are the relevant contents of myapp/settings.py:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'allauth',
'allauth.account',
'rest_auth.registration',
)

TEMPLATE_CONTEXT_PROCESSORS = (
# Required by allauth template tags
"django.core.context_processors.request",
# allauth specific context processors
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)

AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of allauth
"django.contrib.auth.backends.ModelBackend",
# allauth specific authentication methods, such as login by e-mail
"allauth.account.auth_backends.AuthenticationBackend",
)

Thanks!

Dependency on django-registration

Hi

My Project is a Application to which only paid/known users can get access to. I'm somewhat hesitant to add django-registration as a dependency to my project, because a) there is no need for people to register themselfs and b) django-registration is abadoned atm (see https://bitbucket.org/ubernostrum/django-registration/wiki/Home) and does not support python 3.2 (altough 3.3 is supported again because it allows u'…' string notation).

django-rest-auth clearly can have the depenency for the /rest-auth/register/ call, but /login, /logout, /user and /password/* should not depend on django-registration

Regards,
Peter

Email Confirmation has wrong url

Hi,
I'm currently using django-rest-auth for normal user registration. Problem is every-time a user signups, the email confirmation link has the wrong url.
Eg. User signs up at www.example.com the email confirmation url is www.api.example.com which should not be so. I'm wondering how I could fix that

Feature request

Small application demo with django+rest_framework+allauth+rest_auth will be nice.
Living demo even better. With custom profiles - You are on top of django world.
For unexperienced users (like me) it's sligtly difficult imagine how all this things work together.

Django is lack of good authentication with registration, modern (REST) and complex system.
Rails guys got 'Devise' (take a look, it's worth spending time), in django: django-registration - abandoned, userena - no python3 and django 1.7 support, other are lack of features.

Session cookie age for Facebook Rest Auth

It seems like the session for facebook auth lasts only a few hours. Is there a default Session_cookie_age setting that I can override in settings.py with regards to rest_auth? As far as I know, Django's default cookie age is 2 weeks so that shouldn't be whats causing this issue,right?

Type Error at /rest-auth/login/

TypeError at /auth/login/
get_serializer() got an unexpected keyword argument 'instance'

Using GET. This is because Login.get_serializer() doesn't accept any args or kwargs.

How to create extended user Profile?

I've created the following user serializer for when the user signs up

class UserSignUpSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ('email',)

    def create(self, validated_data):
        user = User(email=validated_data['email'], username=validated_data['email'])
        user.set_password(validated_data['password'])
        user.save()
        profile = UserProfile(user=user)
        profile.save()
        return user

However, this doesn't create a new UserProfile that's associated with the User model.

My UserProfile model is defined as follows:

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    #Some Fields for UserProfile

Social REST auth with REST_SESSION_LOGIN = True

SocialLogin view class should have its own login method to assign some backend to user object, because dango.contrib.auth.login requires backend property, that usually is assigned by authenticate method

currently i've just made a dirty fix like this

class SocialLogin(OldSocialLogin):
    def login(self):
        # import ipdb; ipdb.set_trace()
        self.user = self.serializer.validated_data['user']
        self.token, created = self.token_model.objects.get_or_create(
            user=self.user)
        if getattr(settings, 'REST_SESSION_LOGIN', True):
            if not hasattr(self.user, 'backend'):
                self.user.backend = 'django.contrib.auth.backends.ModelBackend'
            login(self.request, self.user)

but im sure it is not the most beautiful solution

Problem with login.

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.

Social login with VK

Hi,

I have endpoints for social login with Facebook and VK. Facebook login works perfect. But adapter for VK is little bit different and it needs also uid to complete login. Is there way to configure SocialLoginSerializer like other serializer, so I can override it?

Thank you.

token timeout

Sorry could not see a mailing list to post this

How do we set the session timeout using the module ?

419 Authentication Timeout (non standard) — Session has expired

Missing requires: 'six'

The 'six' package doesn't get installed with pip install django-res-auth, but is imported in the utils.py file. I don't know if this still needs to be used and therefore installed with the requirements or should be removed from use.

Missing serializer_class on UserDetails?

UserDetails seems to be missing
serializer_class = UserDetailsSerializer
as without this django-swagger can't inspect the UserDetails class without errors. Can this be added?

How to update extended user profile?

I had a need to store additional information for the user. So I created a UserProfile model by adding this in my models.py

from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    company_name = models.CharField(max_length=100)

Further I made a serializers.py file in my application and added the following to it so that whenever the user is created a UserProfile could be created as well and whenever a user is updated the company_name field would be updated as well.

from rest_framework import serializers
#from django.forms.exceptions import ValidationError
from rest_framework.serializers import ValidationError
from .models import *
from django.contrib.auth import get_user_model
import re


class UserProfileSerializer(serializers.ModelSerializer):
    #follows = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
    class Meta:
        model = models.UserProfile
        fields = ('company_name',)

class UserSerializer(serializers.ModelSerializer):
    profile = UserProfileSerializer()

    class Meta:
        model = User
        fields = ('username', 'email', 'profile')

    def create(self, validated_data):
        profile_data = validated_data.pop('profile')
        user = User.objects.create(**validated_data)
        Profile.objects.create(user=user, **profile_data)
        return user

    def update(self, instance, validated_data):
        profile_data = validated_data.pop('profile')
        # Unless the application properly enforces that this field is
        # always set, the follow could raise a `DoesNotExist`, which
        # would need to be handled.
        profile = instance.profile

        instance.username = validated_data.get('username', instance.username)
        instance.email = validated_data.get('email', instance.email)
        instance.save()

        profile.company_name = profile_data.get(
            'company_name',
            profile.company_name
        )
        profile.save()

        return instance

However, the changes I made to serializers.py don't seem to be having any effect.
How would I go about updating the company_name field when the user profile is updated on this url http://localhost:8080/rest-auth/user/ ? FYI, I'm trying all this in the demo application that ships with application.

PasswordReset requires django.contrib.auth urls

The PasswordReset view depends on django.contrib.auth.views.password_reset_confirm. Therefore we need url(r'^', include('django.contrib.auth.urls')), in urlpatterns.
As I'm using django-allauth this wasn't the case in my situation.
Maybe this could be added to the docs.

When using allauth it doesn't make sense to use the default django auth views right?
Should I overwrite all PasswordReset views and serializers to implement the allauth 'way' of dealing with password resets?

AttributeError at /rest-auth/registration/

'function' object has no attribute 'copy'

A GET request to the Register view seems to have a namespace issue regarding 'initial'. APIView has an 'initial' method (regarding initial steps), but SignupView (or rather, FormMixin) has an 'initial' property (regarding initial form data). The GET request is trying to copy the initial form data, but is finding a class method instead.

Using Django 1.6.8, DRF 2.4.4

Improperly configured on email verification

Hi, I really like this project!
I'd like to see a better explained integration or maybe even some test project like one I'm putting together now, plain latest installs of django/drf/allauth and rest-auth

I've setup a mini project on which I get:
ImproperlyConfigured at /rest-auth/registration/account-confirm-email//

The thing is:
https://github.com/Tivix/django-rest-auth/blob/master/rest_auth/registration/urls.py#L12
has a TemplateView initialized wihout a template. So this should break!

Do we need to override and provide custom verification logic for this process?

AttributeError at /rest-auth/register/ 'NoneType' object has no attribute '_meta'

I tried to simply install this without adding anything per the readme.
trying:

http://localhost:8000/rest-auth/register/

getting some issue with models being None:

AttributeError at /rest-auth/register/ 'NoneType' object has no attribute '_meta'

trace:
https://gist.github.com/oxbits/1d30bd8f7fb51836071d

using Ubuntu trusty 64 via vagrant

$ pip list
apt-xapian-index (0.45)
argparse (1.2.1)
chardet (2.0.1)
Cheetah (2.4.4)
cloud-init (0.7.5)
colorama (0.2.5)
configobj (4.7.2)
Django (1.6.5)
django-filter (0.7)
django-registration (1.0)
django-rest-auth (0.2.1)
djangorestframework (2.3.14)
html5lib (0.999)
httplib2 (0.8)
ipython (2.1.0)
jsonpatch (1.3)
jsonpointer (1.0)
keyring (3.5)
Landscape-Client (14.01)
launchpadlib (1.10.2)
lazr.restfulclient (0.13.3)
lazr.uri (1.0.3)
Markdown (2.4.1)
oauth (1.0.1)
PAM (0.4.2)
pip (1.5.4)
prettytable (0.7.2)
pycrypto (2.6.1)
pycurl (7.19.3)
Pygments (1.6)
pygobject (3.12.0)
pyOpenSSL (0.13)
pyserial (2.6)
python-apt (0.9.3.5)
python-debian (0.1.21-nmu2ubuntu2)
PyYAML (3.10)
requests (2.2.1)
SecretStorage (2.0.0)
setuptools (3.3)
simplejson (3.3.1)
six (1.5.2)
ssh-import-id (3.21)
Twisted-Core (13.2.0)
Twisted-Names (13.2.0)
Twisted-Web (13.2.0)
urllib3 (1.7.1)
wadllib (1.3.2)
wsgiref (0.1.2)
zope.interface (4.0.5)

Django 1.7 compatibility

Using Django 1.7 seems to cause some issues regarding this library. I think the instances of get_user_model() in serializers.py need to be updated to settings.AUTH_USER_MODEL.

As django-registration is now abandoned and has problems with Django 1.7 someone has made django-registration-redux to fix the problems.

Does anything else need to be changed for 1.7?

Testing google social auth login results in an error

More or less duplicated the test for the social login for facebook, but change it to google as the provider. It does not work if I have the django messages app installed, but work fine if I remove it.

  File "/Users/xxx/.virtualenvs/yyy/lib/python3.4/site-packages/allauth/account/utils.py", line 157, in complete_signup
    signal_kwargs=signal_kwargs)
  File "/Users/xxx/.virtualenvs/yyy/lib/python3.4/site-packages/allauth/account/utils.py", line 140, in perform_login
    {'user': user})
  File "/Users/xxx/.virtualenvs/yyy/lib/python3.4/site-packages/allauth/account/adapter.py", line 263, in add_message
    extra_tags=extra_tags)
  File "/Users/xxx/.virtualenvs/yyy/lib/python3.4/site-packages/django/contrib/messages/api.py", line 23, in add_message
    "not '%s'." % request.__class__.__name__)
TypeError: add_message() argument must be an HttpRequest object, not 'Request'.

Demo email confirmation link invalid

In the demo provided, if you click the link in the email confirmation email and follow it through, an attempt is made to react /accounts/login/, which isn't defined

Login should return users id

Hi, I'm currently using django-rest-auth and I love it, but I think it would be better if a login users id is returned with the key and not just the key.

DRF 3 changes HttpRequest to Request

When I do registration, one exception raise as follow:

add_message() argument must be an HttpRequest object, not 'Request'.

The upper level code related to django-rest-auth is at /rest_auth/registration/views.py#L27

def form_valid(self, form):
    self.user = form.save(self.request)
    return complete_signup(self.request, self.user,
                           app_settings.EMAIL_VERIFICATION,
                           self.get_success_url()) 

And add_message in django will check request object:

if not isinstance(request, HttpRequest):
    raise TypeError("add_message() argument must be an HttpRequest object, "
                    "not '%s'." % request.__class__.__name__) 

but docs from drf says:

Note that due to implementation reasons the Request class does not inherit from HttpRequest class, but instead extends the class using composition.

Related stackoverflow thread:
http://stackoverflow.com/questions/27456273/using-django-message-framework-with-rest-framework

I will make a pull request if you guys are going to support drf 3.0.

How to set access token?

curl -i -X POST http://127.0.0.1:8000/%2Frest-auth/facebook/
HTTP/1.0 400 BAD REQUEST
Date: Mon, 09 Feb 2015 05:10:17 GMT
Server: WSGIServer/0.1 Python/2.7.9
Vary: Accept, Cookie
Content-Type: application/json
Content-Language: ru
Allow: POST, OPTIONS

{"access_token":["Обязательное поле."]}

CSRF Failed: CSRF token missing or incorrect.

Hi,

Thanks for your work! I'm using django-rest-auth, I followed all the steps to implement it but for the following endpoints I get a "CSRF Failed: CSRF token missing or incorrect.":

/rest-auth/logout/ (POST)
/rest-auth/user/ (PUT/PATCH)

I've already implemented TokenAuthentication for Django Rest Framework, what I should do now?

BrowsableAPIRenderer throws on /auth/user/ without AUTH_PROFILE_MODULE

Hi

a followup to #3: when leaving out AUTH_PROFILE_MODULE, the /auth/user/ correctly returns json when requested to. Calling it in the Browser fails with

Traceback:
File "/home/peter/AAA-WssIt/django-vs-extjs/lib/python3.3/site-packages/django/core/handlers/base.py" in get_response
  137.                 response = response.render()
File "/home/peter/AAA-WssIt/django-vs-extjs/lib/python3.3/site-packages/django/template/response.py" in render
  105.             self.content = self.rendered_content
File "/home/peter/AAA-WssIt/django-vs-extjs/lib/python3.3/site-packages/rest_framework/response.py" in rendered_content
  59.         ret = renderer.render(self.data, media_type, context)
File "/home/peter/AAA-WssIt/django-vs-extjs/lib/python3.3/site-packages/rest_framework/renderers.py" in render
  601.         context = self.get_context(data, accepted_media_type, renderer_context)
File "/home/peter/AAA-WssIt/django-vs-extjs/lib/python3.3/site-packages/rest_framework/renderers.py" in get_context
  551.         raw_data_post_form = self.get_raw_data_form(view, 'POST', request)
File "/home/peter/AAA-WssIt/django-vs-extjs/lib/python3.3/site-packages/rest_framework/renderers.py" in get_raw_data_form
  490.                 serializer = view.get_serializer(instance=obj)
File "/home/peter/AAA-WssIt/django-vs-extjs/lib/python3.3/site-packages/rest_framework/generics.py" in get_serializer
  99.         serializer_class = self.get_serializer_class()
File "/home/peter/AAA-WssIt/django-vs-extjs/lib/python3.3/site-packages/rest_framework/generics.py" in get_serializer_class
  248.             % self.__class__.__name__

Exception Type: AssertionError at /api/auth/user/
Exception Value: 'UserDetails' should either include a 'serializer_class' attribute, or use the 'model' attribute as a shortcut for automatically generating a serializer class.

Environment:

Request Method: GET
Request URL: http://localhost:8000/api/auth/user/

Django Version: 1.6.5
Python Version: 3.3.2
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'rest_framework',
 'rest_framework.authtoken',
 'rest_auth',
 'frontend',
 'polls')
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')

REST_FRAMEWORK Settings

{'DEFAULT_AUTHENTICATION_CLASSES': ('rest_framework.authentication.SessionAuthentication',),
 'DEFAULT_FILTER_BACKENDS': ['rest_framework.filters.DjangoFilterBackend',
                             'rest_framework.filters.OrderingFilter'],
 'DEFAULT_MODEL_SERIALIZER_CLASS': 'rest_framework.serializers.HyperlinkedModelSerializer',
 'DEFAULT_PERMISSION_CLASSES': ['rest_framework.permissions.DjangoModelPermissions'],
 'MAX_PAGINATE_BY': 100,
 'ORDERING_PARAM': 'sort',
 'PAGINATE_BY': 10,
 'PAGINATE_BY_PARAM': 'limit'}

Login with email

I'm using registration via email.

ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True   
ACCOUNT_USERNAME_REQUIRED = False

Is there a way to sign in using this or should I write my own Login view? Looks like we currently only support username+password (from AuthTokenSerializer)

Failed Authentication Should Result in HTTP 401

I've got django-rest-auth 0.3.4 and django-rest-framework 3.1.0 configured and working correctly with TokenAuth on Django 1.8c1.

However, I note that when providing incorrect username/password to the api/rest-auth/login endpoint, it responds with HTTP 400 (Bad Request).

It seems that the correct status code, and the one most consistent with Rest Framework auth docs, would be HTTP 401 (Unauthorized).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.