python-graphql-client icon indicating copy to clipboard operation
python-graphql-client copied to clipboard

Issue with authentication using jwt token in subscription

Open RenjilaRajan opened this issue 4 years ago • 1 comments

Could you please provide an example of how to call subscription using endpoint and the jwt authentication using email and api key . I am getting jwt token using resp = requests.post(ServerUrl, auth=(email,apiKey)) .

I tried the following options for subscriptions.

  1. auth = HTTPBasicAuth(email, apiKey) client = GraphqlClient(endpoint="wss://xxxx/graphql",options={"auth": auth} ) asyncio.run(client.subscribe(query=query,variables={'id': 'xx'}, handle=callback))

  2. resp = requests.post(ServerUrl, auth=(email,apiKey)) jwtToken = resp.json()['access_token'] client = GraphqlClient(endpoint="wss://xxxx/graphql") client.headers = {'Authorization': jwtToken} asyncio.run(client.subscribe(query=query,variables={'id': 'xx'}, handle=callback))

I am getting the following error in both the cases. websockets.exceptions.InvalidURI:xxx/graphql isn't a valid URI .

Thanks in advance, Renjila

RenjilaRajan avatar Jul 06 '21 09:07 RenjilaRajan

you could use the integrated headers API found in the source code. headers={'Authorisation': "Baerer ... while init the GraphqlClient

PiecePaperCode avatar Oct 02 '22 22:10 PiecePaperCode