Skip to content

Commit 68e9d13

Browse files
committed
Pass API key using authorization header
1 parent 325a336 commit 68e9d13

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

detectlanguage/client.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ def __init__(self, configuration):
77
self.configuration = configuration
88

99
def get(self, path, payload = {}):
10-
r = requests.get(self.url(path), params=self.data(payload), headers = self.headers())
10+
r = requests.get(self.url(path), params=payload, headers = self.headers())
1111
return self.handle_response(r)
1212

1313
def post(self, path, payload):
14-
r = requests.post(self.url(path), json=self.data(payload), headers = self.headers())
14+
r = requests.post(self.url(path), json=payload, headers = self.headers())
1515
return self.handle_response(r)
1616

1717
def handle_response(self, r):
@@ -30,9 +30,8 @@ def url(self, path):
3030
def protocol(self):
3131
return 'https' if self.configuration.secure else 'http'
3232

33-
def data(self, payload):
34-
payload.update({ 'key': self.configuration.api_key })
35-
return payload
36-
3733
def headers(self):
38-
return { 'User-Agent': self.configuration.user_agent }
34+
return {
35+
'User-Agent': self.configuration.user_agent,
36+
'Authorization': 'Bearer ' + self.configuration.api_key,
37+
}

0 commit comments

Comments
 (0)