Hello friend,

I noticed that you are using the standard token authentication system. 
However, this method does not correspond to JWT.

Since you want to use authentication through JWT with DRF, you must use:

1) A JWT library that implements this type of authentication which helps 
you to create a login route to obtain the access token, route to the 
refresh token, or other routes and resources you need. I can recommend you: 
Simple JWT (my favorite) 
https://github.com/SimpleJWT/django-rest-framework-simplejwt or REST 
framework JWT Auth - https://jpadilla.github.io/django-rest-framework-jwt /

2) Next, you must correctly configure these Django modules.

3) When everything is properly configured, you must first obtain the access 
token and refresh token through a previously created user login.

4) Once you have the access token, you must send it to the request head as 
follows, for example:
 {Authorization: "Bearer 
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU5NTYwMzIyNSwianRpIjoiY2QxYTRiYWJiZTgzNDVhMjlkMGJmYTIzNTc0Zjk0ZjEiLCJ1c2VyX2lkIjo4fQ.i6bmtiqFyWyxo7mMuZxQjN9RvM-DjaiOwRVxeRBdiwM"}

5) Every 5 minutes you must request a new access token through the refresh 
token, but now in the body of the request:
 { "Refresh", 
"ppADdAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU5NTYwMzIyNSwianRpIjoiY2QxYTRiYWJiZTgzNDVhMjlkMGJmYTIzNTc0Zjk0ZjEiLCJ1c2VyX2lkIjo4fQ.i6bmtiqFyWyxo7mMuZxQjN9RvM-DjaiOwRVxeRBccdSA"}

Read this article: 
https://simpleisbetterthancomplex.com/tutorial/2018/12/19/how-to-use-jwt-authentication-with-django-rest-framework.html

Hope this helps!

See you later!

Em sábado, 25 de julho de 2020 16:52:38 UTC-3, ola neat escreveu:
>
> hey guy i got an issue implementing jwt in my drf project, i've got it 
> installed and when the user signs up or login the token get generated but 
> when i use the same token to test other end point i get 
> i've got my code and response attached 
> {
> "detail": "Authentication credentials were not provided."
> }
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/069d7c8c-3aba-457c-ba7c-b047779a5f29o%40googlegroups.com.

Reply via email to