728x90
Django JWT 구현 코드
pip install djangorestframework-simplejwt
pip install and setting in setting.py
INSTALLED_APPS = [
...
'rest_framework_simplejwt',
...
]
authentication setting
REST_FRAMEWORK = {
...
'DEFAULT_AUTHENTICATION_CLASSES': (
...
'rest_framework_simplejwt.authentication.JWTAuthentication',
)
...
}
Use simplejwt library and url setting
fromrest_framework_simplejwt.viewsimport (
TokenObtainPairView,
TokenRefreshView,
TokenVerifyView,
)
urlpatterns = [
...
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
path('api/token/verify/', TokenVerifyView.as_view(), name='token_verify'),
...
]
더 자세한 정보는 아래를 참조해주세요
https://chlendyd7.notion.site/jwt-5295040f5d964165b95098d5945f7559?pvs=4
'Django > restframework' 카테고리의 다른 글
JWT (0) | 2024.04.24 |
---|---|
Restframework JWT 설정 (0) | 2024.01.29 |
Routers (0) | 2024.01.23 |
Viewsets (2) | 2024.01.22 |
Generic views (0) | 2024.01.18 |