Skip to content

Commit

Permalink
Merge pull request #51 from bbuccianti/fix-hooks
Browse files Browse the repository at this point in the history
handle_auth_response: wrong secret and raise error
  • Loading branch information
dgw authored Dec 4, 2019
2 parents 5619856 + f0e433f commit 24e7e77
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sopel_modules/github/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,14 @@ def handle_auth_response():
channel = state.split(':')[1]

data = {'client_id': sopel_instance.config.github.client_id,
'client_secret': sopel_instance.config.github.secret,
'code': code}
'client_secret': sopel_instance.config.github.client_secret,
'code': code}
raw = requests.post('https://github.com/login/oauth/access_token', data=data, headers={'Accept': 'application/json'})
try:
res = json.loads(raw.text)

if 'error' in res:
raise ValueError('{err}: {desc}'.format(err=res['error'], desc=res['error_description'])
if 'scope' not in res:
raise ValueError('You\'ve already completed authorization on this repo')
if 'write:repo_hook' not in res['scope']:
Expand Down

0 comments on commit 24e7e77

Please sign in to comment.