Skip to main content

django-basic-jwt-auth

Accounts is a Django app to authenticate user using JWT Token on custom users.

1. Install dependencies

$ pip install rest_framework
$ pip install rest_framework_simplejwt
$ pip install django-cors-headers
$ install -i https://test.pypi.org/simple/ django-basic-jwt-auth

2. Add "accounts" to your INSTALLED_APPS setting.py like this:

INSTALLED_APPS = [
    ...
    'accounts',
    ...
]

3. add the following codes to the settings.py:

AUTH_USER_MODEL = 'accounts.User'
...
... 
REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    ],
}

4. Run migrations

$ python manage.py migrate

5. Access the views

from django.contrib import admin
from django.urls import path
from accounts import views
from rest_framework_simplejwt import views as jwt_views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('register/', views.CreateAccountView.as_view(),
         name='user-register'),
    path('token/', jwt_views.TokenObtainPairView.as_view(),
         name='token_obtain_pair'),
    path('token/refresh/', jwt_views.TokenRefreshView.as_view(),
         name='token_refresh'),
    path('users/', views.UserListView.as_view(),
         name='user-list'),
    path('users/<uuid:id>/', views.UserDetailView.as_view(),
         name='user-detail'),
    path('me/', views.CurrentUserView.as_view(),
         name='me'),
]

Metadata

Release files for django-basic-jwt-auth 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-basic-jwt-auth 0.2
File Size Uploaded
django-basic-jwt-auth-0.2.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-basic-jwt-auth 0.2
File Interpreter ABI Platform
django_basic_jwt_auth-0.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / django-basic-jwt-auth-0.2.tar.gz

Download URL django-basic-jwt-auth-0.2.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8e92a636fc973735cf9909e963a303fd9947305b8cb3a67f862adc3efb5b4bdc
BLAKE2b-256 checksum
How to use checksums
baf83a5eab4e654b0657ceeb32f114a9f532fc52a6f847a6ed290be55e8f092a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

Release files / django_basic_jwt_auth-0.2-py3-none-any.whl

Download URL django_basic_jwt_auth-0.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e642296c87565b51b56345e010dd96cc17644ad40018b3a509e9d6c10170c8f1
BLAKE2b-256 checksum
How to use checksums
ad261ed80423e119d50ff084221e83b45ad800561ca7812ef9aa498e44c3d9b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page