I'm trying to do websocket authentication. I can pass the token via query_string. How to verify a token and decode it?
class WebSocketJWTAuthMiddleware:
def __init__(self, app):
self.app = app
async def __call__(self, scope, receive, send):
parsed_query_string = parse_qs(scope["query_string"])
token = parsed_query_string.get(b"token")[0]
print(token)
try:
# Token validation
except:
pass
return await self.app(scope, receive, send)