📝 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,10 +1,9 @@
from datetime import datetime, timedelta
from typing import Optional
import jwt
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from jwt import PyJWTError
from jose import JWTError, jwt
from passlib.context import CryptContext
from pydantic import BaseModel
@@ -99,7 +98,7 @@ async def get_current_user(token: str = Depends(oauth2_scheme)):
if username is None:
raise credentials_exception
token_data = TokenData(username=username)
except PyJWTError:
except JWTError:
raise credentials_exception
user = get_user(fake_users_db, username=token_data.username)
if user is None: