Authenticating with JWT token in Django
<p>I am beginner in Django and I am learning about JWT token from here.</p>

<p><a href="http://getblimp.github.io/django-rest-framework-jwt/#rest-framework-jwt-auth" rel="nofollow">http://getblimp.github.io/django-rest-framework-jwt/#rest-framework-jwt-auth</a></p>

<p>I have already set up in my settings.py.</p>

<pre><code>REST_FRAMEWORK = {
   'DEFAULT_AUTHENTICATION_CLASSES':
        (
         'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
         ),

    'DEFAULT_MODEL_SERIALIZER_CLASS':
        'rest_framework.serializers.ModelSerializer',

    'DEFAULT_PERMISSION_CLASSES':
    (
    'rest_framework.permissions.IsAuthenticated',
        )
}
</code></pre>

<p>If I do curl, I actually get back my token. </p>

<pre><code>curl -X POST -d "username=khant&amp;password=khant" http://127.0.0.1:8000/api-token-auth/
</code></pre>

<p>But when I access my protected url, </p>

<pre><code>curl -H "Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImtoYW50IiwidXNlcl9pZCI6OCwiZW1haWwiOiJraGFudEBnbWFpbC5jb20iLCJleHAiOjE0NzQ5MDQxNTJ9.jaZ3HwsXjx7Bk2ol5UdeE8UUlq4OEGCbnb1T8vDhO_w" http://127.0.0.1:8000/dialogue_dialoguemine/
</code></pre>

<p>It always say this when I access from web. Localhost is okay for me.</p>

<blockquote>
  <p>{"detail":"Authentication credentials were not provided."}</p>
</blockquote>

<p>In my protected url, I just write simple api to query. May I know how to solve this? </p>

<pre><code>class DialogueMineView(generics.ListAPIView):
    permission_classes = (IsAuthenticated,)

    serializer_class = DialogueSerializer
    paginate_by = 2

    def get_queryset(self):

        user = self.request.user
        return Dialogue.objects.filter(owner=user)
</code></pre>

<p>I know now. For my case, I am not okay only on web. I check from this link.</p>

<p><a href="http://stackoverflow.com/questions/26906630/django-rest-framework-authentication-credentials-were-not-provided">Django Rest Framework - Authentication credentials were not provided</a></p>

<p>It say I need to add </p>

<pre><code>WSGIPassAuthorization On
</code></pre>

<p>in my httpd.conf in apache directory. It is okay now. </p>

python django jwt