I´m having hard time to use GraphQL with Python since the suggested library: gql is completely undocumented.
How ever I found out that to provide the api url I need to pass a RequestsHTTPTransport object to Client like this:
client = Client(transport=RequestsHTTPTransport(url='https://some.api.com/v3/graphql'))
but how to provide credentials like the Bearer Key?
PS I noticed that it RequestsHTTPTransport accepts also a auth param which is described as:
:param auth: Auth tuple or callable to enable Basic/Digest/Custom HTTP Auth
how ever I still can not find out how to create this tuple or callable to work with a Bearer Key :(
Thanks in advise
You can add it in the headers.
reqHeaders = {
'x-api-key' : API_KEY,
'Authorization': 'Bearer ' + TOKEN_KEY // This is the key
}
_transport = RequestsHTTPTransport(
url=API_ENDPOINT,
headers = reqHeaders,
use_json=True,
)
client = Client(
transport = _transport,
fetch_schema_from_transport=True,
)