title: Django (using TokenAuthentication): "non_field_errors": "Unable to log in with provided credentials?
body: <p>I'm using httpie to test my custom authentication.</p>
  
  <pre><code>http POST http://127.0.0.1:8000/api-token-auth/ username='username1' password='Password123'
  </code></pre>
  
  <p>I did create a custom auth object using <code>AbstractUser</code>. </p>
  
  <p>Using TokenAuthentication, I followed the docs and added my custom TokenAuthentication in my <code>REST_FRAMEWORK</code> settings:</p>
  
  <pre><code>REST_FRAMEWORK = {
  'DEFAULT_AUTHENTICATION_CLASSES': (
      'regis.models.CustomAuthentication',
      )
  }
  </code></pre>
  
  <p>And added <code>rest_framework.authtoken</code> in my installed apps.</p>
  
  <p>My <code>AUTHENTICATION_BACKEND</code> is as follows:</p>
  
  <pre><code>AUTHENTICATION_BACKENDS = [ 'regis.models.CustomAuthentication' ]
  </code></pre>
  
  <p>And here is my custom authentication class:</p>
  
  <pre><code>class CustomAuthentication(authentication.TokenAuthentication):
      def authenticate(self, request):
          username = request.META.get('X_USERNAME')
          print(username)
          user_model = get_user_model()
          if not username:
              return None
      try:
          user = user_model.objects.get(username=username)
      except User.DoesNotExist:
          raise exceptions.AuthenticationFailed('No such user')
      return (user, None)
  </code></pre>
  
  <p>urls.py:</p>
  
  <pre><code>urlpatterns += [
      url(r'^api-token-auth/', views.obtain_auth_token),
  
      ]
  </code></pre>
  
  <p>I'm pretty much following the DRF docs (<a href="http://www.django-rest-framework.org/api-guide/authentication/#custom-authentication" rel="nofollow noreferrer">http://www.django-rest-framework.org/api-guide/authentication/#custom-authentication</a>). If there's any additional info needed to solve this, please let me know and I'll update. Any help on what I'm missing would be great. </p>
  
  <p>To add: Just out of curiosity, do I need to make a custom authentication system if I have a custom user?</p>
  
  <p>UPDATE:</p>
  
  <p>I just deleted the class above, and just added the <code>rest_framework.authentication.TokenAuthentication</code> in my REST_FRAMEWORK settings. I'm still using a custom authentication which fetches my user.</p>
  
  <p>It looks like this (not going to format it. SO sucks at formatting code from VIM):</p>
  
  <pre><code>class CustomAuthentication(object):
  def authenticate(self, email=None, password=None):
  
      User = get_user_model()
      try:
          user = User.objects.get(email=email)
      except User.DoesNotExist:
          return None
      if user.check_password(password):
          return user
  
      return None
  
  def get_user(self, user_id):
      try:
          user_model = get_user_model()
          user = user_model.objects.get(pk=user_id)
      except User.DoesNotExist:
          return None
  </code></pre>
  
  <p>I used this Django docs to create that code: <a href="https://docs.djangoproject.com/en/1.10/topics/auth/customizing/" rel="nofollow noreferrer">https://docs.djangoproject.com/en/1.10/topics/auth/customizing/</a></p>