Skip to content

Commit 92fcae7

Browse files
committed
Use Authorization header for auth on GitHub API
`access_token` query parameter does not work anymore. See https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/ Fixes #11
1 parent 34adaff commit 92fcae7

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tarantoolbot.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ def parse_comment(body):
8787
def send_comment(body, issue_api, to):
8888
create_event(to, 'send_comment', body)
8989
body = {'body': '@{}: {}'.format(to, body)}
90-
url = '{}/comments?access_token={}'.format(issue_api, token)
91-
r = requests.post(url, json=body)
90+
url = '{}/comments'.format(issue_api)
91+
headers = {
92+
'Authorization': 'token {}'.format(token),
93+
}
94+
r = requests.post(url, json=body, headers=headers)
9295
r.raise_for_status()
9396
print('Sent comment: {}'.format(r.status_code))
9497

@@ -98,8 +101,11 @@ def send_comment(body, issue_api, to):
98101

99102
def get_comments(issue_api):
100103
body = {'since': '1970-01-01T00:00:00Z'}
101-
url = '{}/comments?access_token={}'.format(issue_api, token)
102-
r = requests.get(url, json=body)
104+
url = '{}/comments'.format(issue_api)
105+
headers = {
106+
'Authorization': 'token {}'.format(token),
107+
}
108+
r = requests.get(url, json=body, headers=headers)
103109
r.raise_for_status()
104110
return r.json()
105111

@@ -117,8 +123,11 @@ def create_issue(title, description, src_url, author):
117123
description = '{}\nRequested by @{} in {}.'.format(description, author,
118124
src_url)
119125
body = {'title': title, 'body': description}
120-
url = '{}/issues?access_token={}'.format(doc_repo_url, token)
121-
r = requests.post(url, json=body)
126+
url = '{}/issues'.format(doc_repo_url)
127+
headers = {
128+
'Authorization': 'token {}'.format(token),
129+
}
130+
r = requests.post(url, json=body, headers=headers)
122131
r.raise_for_status()
123132
print('Created issue: {}'.format(r.status_code))
124133

0 commit comments

Comments
 (0)