Код: Выделить всё
/auth/token
Код: Выделить всё
@router.post('/token',status_code=status.HTTP_201_CREATED)
def login_user(data:OAuth2PasswordRequestForm = Depends(),db : Session = Depends(get_db)):
access_token = login_user_account(data=data,db=db)
payload = {
"access_totken":access_token.access_token,
"token_type": "Bearer"
}
return JSONResponse(content = payload)
Код: Выделить всё
async def authenticate(self, conn):
guest = AuthCredentials(['unauthenticated']), UnauthenticatedUser()
print("Headers:", conn.headers)
if 'authorization' not in conn.headers:
return guest
token = conn.headers.get('authorization').split(' ')[1]
Подробнее здесь: https://stackoverflow.com/questions/792 ... -in-the-au