P
P
Prid32021-11-12 01:21:01
JSON Web Token
Prid3, 2021-11-12 01:21:01

How to use jwt tokens in django-oauth-toolkit without adding them to the database?

I've been working on separating the auth server from the resource server using django-oauth-toolkit.
I also wrote my jwt token generator:

from rest_framework_simplejwt.tokens import RefreshToken

def my_acces_token_generator(request, refresh_token=False):
  refresh = RefreshToken.for_user(request.user)
  return str(refresh.access_token)

def my_refresh_token_generator(request, refresh_token=False):
  refresh = RefreshToken.for_user(request.user)
  return str(refresh)


And now I noticed that my jwt tokens are added to the database created by django-oauth-toolkit, but the essence of jwt is not to store them in the database. Tell me how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
veryoriginalnickname, 2021-11-12
@veryoriginalnickname

I don’t know about drf, but it seems that refresh token is imported in your code, and it itself should be stored somewhere. In theory, you need to abandon the refresh and use only the access token, apparently you need to import it , and then do something with it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question