Skip to content

Commit

Permalink
handle_auth: add error message and correct secret field from config
Browse files Browse the repository at this point in the history
  • Loading branch information
bbuccianti committed Dec 4, 2019
1 parent 5619856 commit 527d520
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion 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,
'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}: {des}'.format(err=res['error'], des=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 527d520

Please sign in to comment.