Skip to content

Instantly share code, notes, and snippets.

View ARYAN-NIKNEZHAD's full-sized avatar
🎯
Focusing

Aryan ARYAN-NIKNEZHAD

🎯
Focusing
  • Hyponet
  • Iran
  • 03:52 (UTC +03:30)
View GitHub Profile
@ARYAN-NIKNEZHAD
ARYAN-NIKNEZHAD / Django_Channels3_Custom_Auth_Middleware.py
Last active July 13, 2023 17:21 — forked from AliRn76/Django_Channels3_Custom_Auth_Middleware.py
Token authorization middleware for Django Channels 3
from django.contrib.auth.models import AnonymousUser
from rest_framework.authtoken.models import Token
from channels.db import database_sync_to_async
from channels.middleware import BaseMiddleware
from project.settings import SIMPLE_JWT, SECRET_KEY
from urllib.parse import parse_qs
import jwt
@database_sync_to_async
def get_user(token_key):