Skip to main content

A simple Django app for django-ninja authentication tokens

Project description

ninja-authtoken

A simple Django app for django-ninja authentication tokens

source code : Visit GitHub!

installaton

pip install ninja-authtoken

add ninja-authtoken to django installed app

INSTALLED_APPS = [
    ...
    "authtoken",
    ...
]

set user model in settings.py

Example {AUTH_USER_MODEL = "accounts.USER"}

Usage

for routers

from authtoken.security import APIKeyAuth

auth = APIKeyAuth()

@router.get('profile/', auth=auth)
def profile(request):
    return f"Hello, {request.user}!"

Api Base

from ninja import NinjaAPI
from authtoken.security import APIKeyAuth

#  ...

api = NinjaAPI(auth=APIKeyAuth())

# ...

@api.get("/profile")
def profile(request):
    return f"Hello, {request.user}!"

ـ The token is generated automatically as soon as a new user is created by Signal ـ

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ninja_authtoken-1.0.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

ninja_authtoken-1.0.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file ninja_authtoken-1.0.1.tar.gz.

File metadata

  • Download URL: ninja_authtoken-1.0.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for ninja_authtoken-1.0.1.tar.gz
Algorithm Hash digest
SHA256 06092e36027e63a577276c1921e094e68abda5bd837339248a5fcecdaad8b599
MD5 cc1aa14a880fc11e11e112c17c11046b
BLAKE2b-256 14b756ef149ea2a97fb47de84123d20cffb7ec2d082cb4a765a50208f18aceeb

See more details on using hashes here.

File details

Details for the file ninja_authtoken-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ninja_authtoken-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 281beff64cd7dd0886757f8a320181737e396d38e7e5040832adebd67dfc1e53
MD5 5118bcfe07d5d78195cbae807b293ad3
BLAKE2b-256 48ac36d28a45ff6018b439376559292e11baf29e1676e28c2ee0476a5658b58d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page