Hi, Thank you for your response
In my project I used JWT authentication.

 'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ),
}


# JWT Settings
SIMPLE_JWT = {
    'ACCESS_TOKEN_LIFETIME': timedelta(minutes=20),
    'REFRESH_TOKEN_LIFETIME': timedelta(days=1),

    'AUTH_HEADER_TYPES': ('Bearer',),
    'AUTH_HEADER_NAME': 'HTTP_AUTHORIZATION',
    'USER_ID_FIELD': 'id',
    'USER_ID_CLAIM': 'user_id',
    'USER_AUTHENTICATION_RULE':
'rest_framework_simplejwt.authentication.default_user_authentication_rule',

    'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',),
    'TOKEN_TYPE_CLAIM': 'token_type',
    'TOKEN_USER_CLASS': 'rest_framework_simplejwt.models.TokenUser',

    'JTI_CLAIM': 'jti',

}

INSTALLED_APPS = [
    .........
    'rest_framework_simplejwt',
    .........

]


On Thu, Aug 11, 2022 at 6:39 PM Santosh Rana <[email protected]> wrote:

> Sreebash is right..
> You need to add following code on your settings.py
>
> REST_FRAMEWORK = {
>     'DEFAULT_AUTHENTICATION_CLASSES': [
>         'rest_framework.authentication.BasicAuthentication',
>         'rest_framework.authentication.SessionAuthentication',
>     ]
> }
>
> On Thu, Aug 11, 2022, 6:46 PM Sreebash Chandra Das <
> [email protected]> wrote:
>
>> I think you may not have session authentication in your settings file.
>> That is why you won't provide credentials.
>>
>> On Thu, Aug 11, 2022 at 6:54 PM Salima Begum <
>> [email protected]> wrote:
>>
>>> Hi, Thanks for quick response
>>> I used HTML, CSS as frontend. Here below I attached screenshot
>>>
>>>
>>> On Thu, Aug 11, 2022 at 5:39 PM Sreebash Chandra Das <
>>> [email protected]> wrote:
>>>
>>>> If you properly integrated with the frontend, it should work. I think
>>>> there are some mistakes. Could you  give some screenshot please?
>>>>
>>>> On Thu, Aug 11, 2022 at 5:39 PM Salima Begum <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi,
>>>>> So, I am creating registration API. I written api for registration,
>>>>> Login and then user profile.
>>>>> I tested this API's in Postman here it is working. For User
>>>>> authentication I used JWT authentication. When I test in frontend view 
>>>>> User
>>>>> Profile API is raising an error with
>>>>> ```
>>>>> HTTP 401 Unauthorized Allow: OPTIONS, GET Content-Type:
>>>>> application/json Vary: Accept WWW-Authenticate: Token { "detail":
>>>>> "Authentication credentials were not provided." }
>>>>> ```
>>>>> How to fix this Please help me out how to fix this.
>>>>>
>>>>> Thanks
>>>>> ~Salima
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Django REST framework" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/django-rest-framework/73944851-58f4-4d55-ba67-b88bd55f1cfdn%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/django-rest-framework/73944851-58f4-4d55-ba67-b88bd55f1cfdn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>>
>>>> Sreebash C. Das
>>>> Graduate in B.Sc in CSE
>>>> National University, Bangladesh
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django REST framework" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/django-rest-framework/CALYgY9GRWoq7jgT7sxWTGp7%3Drzb-D8jMSBAXMswahFYB7dxmRA%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-rest-framework/CALYgY9GRWoq7jgT7sxWTGp7%3Drzb-D8jMSBAXMswahFYB7dxmRA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django REST framework" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-rest-framework/CAMSz6bmXYZXSws%3DaR093_QaeiYkw_g19YbXO2NKDfxkJ2e9xxA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-rest-framework/CAMSz6bmXYZXSws%3DaR093_QaeiYkw_g19YbXO2NKDfxkJ2e9xxA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>> Best Regards,
>>
>> Sreebash C. Das
>> Graduate in B.Sc in CSE
>> National University, Bangladesh
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django REST framework" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-rest-framework/CALYgY9HP8BW36J5xFat5mi4Xp99sjk35MbadmJ%2BxdEvo2HSH9Q%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-rest-framework/CALYgY9HP8BW36J5xFat5mi4Xp99sjk35MbadmJ%2BxdEvo2HSH9Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-rest-framework/CAKc113W%3DvFV%2B1vx1704z2Xv%3DZuaBspyfDV5Wxme4px5E%3Dhb%3DyA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-rest-framework/CAKc113W%3DvFV%2B1vx1704z2Xv%3DZuaBspyfDV5Wxme4px5E%3Dhb%3DyA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/CAMSz6bnHPk1UYPZ48AfT%3DMvXSn8TXYcVmbotcbbt6Zd62AmAiA%40mail.gmail.com.

Reply via email to