Closed himalacharya closed 4 years ago
is optional is very helpful if you develop WebSocket which is a token on the query string or path parameter. get_raw_jwt() automatically filled if your request in header or cookie but not for WebSocket
@app.websocket('/ws')
async def websocket(websocket: WebSocket, token: str = Query(...), Authorize: AuthJWT = Depends()):
await websocket.accept()
try:
Authorize.jwt_required("websocket",token=token)
await websocket.send_text("Successfully Login!")
decoded_token = Authorize.get_raw_jwt(token) # here you can pass encoded_token from query string
await websocket.send_text(f"Here your decoded token: {decoded_token}")
except AuthJWTException as err:
await websocket.send_text(err.message)
await websocket.close()
I am not clear on this update. On documentation
How to use new update on this get_raw_jwt() in above example?