简体   繁体   中英

How to get access token and refresh token ( rest_framework_jwt ) in a single API in Django

I need to get access token and refresh token in a single API, Currently I have 2 API's for both access and refresh tokens

url(r'^token-auth', view.ObtainJWTView.as_view(), name='token-auth'),
url(r'^token-refresh', refresh_jwt_token),

I need one more API for both

you don't need more api

url(r'^token-auth', view.ObtainJWTView.as_view(), name='token-auth'),

this will return access and refresh token

and the other will return new access token when you post refresh token

url(r'^token-refresh', refresh_jwt_token),

check docs

https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html#usage

if you are still confused let me know you can make new custome view and use the to serializers used in the above views

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM