Django Rest Framework invalid username/password
<p>Trying to do a simple '<strong>GET</strong>' wih admin credentials returns</p>

<blockquote>
  <p>"detail": "Invalid username/password."</p>
</blockquote>

<p>I have a <em>custom user model</em> where I deleted the <strong>username</strong>, instead I use <strong>facebook_id</strong> :</p>

<pre><code>USERNAME_FIELD = 'facebook_id'
</code></pre>

<hr>

<p>I tried changing the <em>DEFAULT_PERMISSION_CLASSES</em>:</p>

<pre><code>('rest_framework.permissions.IsAuthenticated',), -- doesn't work!
('rest_framework.permissions.IsAdminUser',), -- doesn't work!
</code></pre>

<p>The only one that works is:</p>

<pre><code>('rest_framework.permissions.AllowAny',),
</code></pre>

<p>But I do not want that, since I'm building an API for a Mobile App</p>

<p>I also declared a <em>CustomUserAdmin</em> model and <em>CustomUserCreationForm</em> , apparently this was not the problem</p>

<hr>

<p>Help me understand what needs to be done to fix this annoying problem, I'm guessing it might have something to do with <strong>Permissions/Authentication</strong> or the fact that I CustomUserModel..</p>

<p>Also, let me know if there is a better way for a mobile app client to authenticate to the api</p>

<p>You have the default, and then you have per view.  You can set the default to <code>IsAuthenticated</code>, and then you override your view's particular <code>permission_classes</code>. e.g.</p>

<pre><code>class ObtainJSONWebLogin(APIView):
    permission_classes = ()
</code></pre>

<p>or </p>

<pre><code>class Foo(viewsets.ModelViewSet):
    permission_classes = ()
</code></pre>

python django api django-rest-framework