📝 Update JWT docs to use python-jose (#1610)

* 📝 Update JWT docs with python-jose

* 📝 Update format and use python-jose in docs

* ➕ Add Python-jose to dependencies

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
Brian MboyaandSebastián Ramírez authored and GitHub committed 2020-07-10 20:24:38 +02:00
1 parent 5c01d44ee9
commit 921642dc7b
5 files changed
+32 -25

No files matched your search

+2 -3
View File
@@ -1,14 +1,13 @@
from datetime import datetime, timedelta
from typing import List, Optional
import jwt
from fastapi import Depends, FastAPI, HTTPException, Security, status
from fastapi.security import (
OAuth2PasswordBearer,
OAuth2PasswordRequestForm,
SecurityScopes,
)
from jwt import PyJWTError
from jose import JWTError, jwt
from passlib.context import CryptContext
from pydantic import BaseModel, ValidationError
@@ -121,7 +120,7 @@ async def get_current_user(
raise credentials_exception
token_scopes = payload.get("scopes", [])
token_data = TokenData(scopes=token_scopes, username=username)
except (PyJWTError, ValidationError):
except (JWTError, ValidationError):
raise credentials_exception
user = get_user(fake_users_db, username=token_data.username)
if user is None: