Skip to content
Discussion options

You must be logged in to vote

you could make dependency that take jwt and decode to get the claims/payload then return it

async def get_current_user(token: str = Depends(JWTBearer())) -> dict:
    # skipping verify since its already verified in JWTBearer
    payload = jwt.decode(token, JWT_SECRET, algorithms=[JWT_ALGORITHM], verify_signature=False) 
    return {
        "email": payload.get("email")
    }

you also could save the payloads in request.state while verifying in JWTBearer to skip redecoding the token

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@naheedroomy
Comment options

Answer selected by naheedroomy
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants