JWT Authentication

JSON Web Token auth

security
jwt

Explanation

Generates and verifies JSON Web Tokens for authentication

Examples

JWT token creation

from jose import JWTError, jwt
  
  SECRET_KEY = "secret"
  ALGORITHM = "HS256"
  
  def create_access_token(data: dict):
      to_encode = data.copy()
      return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)