Skip to the content.

Code 401 Class 33 Reading Notes

JSON Web Tokens

JSON Web Token(JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed.

When are they useful?

Structure

——————————–

DRF JWT Authentication

  1. pip install djangorestframework_simplejwt: installs the recommended library by the DRF developers.
  2. settings.py REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework_simplejwt.authentication.JWTAuthentication', ], }
  3. urls.py ` from django.urls import path from rest_framework_simplejwt import views as jwt_views

urlpatterns = [ # Your URLs… path(‘api/token/’, jwt_views.TokenObtainPairView.as_view(), name=’token_obtain_pair’), path(‘api/token/refresh/’, jwt_views.TokenRefreshView.as_view(), name=’token_refresh’), ] `

——————————–

Django Runserver Is Not Your Production Server

Do NOT USE THIS SERVER IN A PRODUCTION SETTING> It has not gone through security audits or performance tests.

——————————–

Things I want to know more about

<—BACK