Skip to content

Commit 7fca142

Browse files
allow other token header names
1 parent 45059d8 commit 7fca142

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

graphqlclient/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ class GraphQLClient:
55
def __init__(self, endpoint):
66
self.endpoint = endpoint
77
self.token = None
8+
self.headername = None
89

910
def execute(self, query, variables=None):
1011
return self._send(query, variables)
1112

12-
def inject_token(self, token):
13+
def inject_token(self, token, headername='Authorization'):
1314
self.token = token
1415

1516
def _send(self, query, variables):
@@ -19,7 +20,7 @@ def _send(self, query, variables):
1920
'Content-Type': 'application/json'}
2021

2122
if self.token is not None:
22-
headers['Authorization'] = '{}'.format(self.token)
23+
headers[self.headername] = '{}'.format(self.token)
2324

2425
req = urllib.request.Request(self.endpoint, json.dumps(data).encode('utf-8'), headers)
2526

0 commit comments

Comments
 (0)