简体   繁体   English

注册后我如何获得 jwt 令牌(djangorestframework)

[英]How can i after registration get jwt tokens (djangorestframework)

from django.conf.urls.static import static 
from django.contrib import admin from django.urls import path, include 
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView, TokenVerifyView

from InternetShop import settings from InternetShopApp.views import *

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/v1/products/', ProductsAPIList.as_view()),
    path('api/v1/products/<int:pk>/', ProductsAPIUpdate.as_view()),
    path('api/v1/productsremove/<int:pk>/', ProductsAPIRemove.as_view()),
    path('api/v1/auth/', include('djoser.urls')),
    path('api/v1/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('api/v1/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
    path('api/v1/token/verify/', TokenVerifyView.as_view(), name='token_verify'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

I need when user successfully register on api/v1/auth/ get jwt tokens in json answer当用户在 api/v1/auth 上成功注册/在 json 中获得 jwt 令牌时,我需要答案

you should enter to this 'api/v1/token/' url and you put that it has asked requirements.你应该输入这个'api/v1/token/' url 并且你说它有要求。 After it gives you two tokens.在它给你两个令牌之后。 First of them access token so you can login with this token.首先他们访问令牌,因此您可以使用此令牌登录。 and second of them refresh token, with it you can refresh when your access token's time is finished.其中第二个刷新令牌,您可以在访问令牌的时间结束时刷新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用“djangorestframework-simplejwt”验证 jwt - How can I verify jwt using "djangorestframework-simplejwt" 如何在 1 分钟后使令牌过期? - how can I expire tokens after 1 minute? DjangoRestFramework - 如何使用“pk”过滤列表? - DjangoRestFramework - How can I use 'pk' to filter a list? DjangoRestFramework如何在视图集中获取用户 - DjangoRestFramework how to get user in viewset 如何在注册时制作 django-rest-framework-jwt 返回令牌? - How can i make django-rest-framework-jwt return token on registration? 如何获取当前用户的JWT信息? - How can I get current user's JWT informations? 我如何使用其他字段来获取 jwt 令牌 - How can i use additional fields to get jwt token 我如何过滤 Json 响应,仅使用 Djangorestframework 中的 DateFilter 将 Year 参数传递给 DateTime 字段 - how can i filter the Json response by only passing the Year parameter to the DateTime field using DateFilter in Djangorestframework 使用 Djoser、django-rest-framework-jwt 和 django-rest-framework 注册后获取 Token - Get Token after Registration with Djoser, django-rest-framework-jwt and django-rest-framework 如何矢量化一系列标记 - How can I vectorize a series of tokens
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM