Token1 [FastAPI] Request에서 user 정보 얻기 해당 내용은 Startlette 공식 페이지와 스택오버플로우를 참고했다. Reqeust에 유저 정보 담기 FastAPI에서 Dependency를 이용해 token에서 유저 정보를 가져오기 위해서는 Request를 사용할 수 있다. async def get_current_user(req: Request): try: token = req.headers.get("authorization") secret_key = token_settings.secret_key algorithms = token_settings.algorithm verified_token = jwt.decode(token, secret_key, algorithms=algorithms) except jwt.ExpiredSignatureError: .. 2023. 4. 23. 이전 1 다음