Correct header check for 2FA required (#1274)

Currently, we were checking for an uppercase header if GitHub was
refusing our authentication because we didn't provide a token. Requests
returns headers with all lowercase. Fix the const, and add a test for
good measure.

Fixes #1273
This commit is contained in:
Steve Kowalik
2019-10-25 21:01:58 +11:00
committed by GitHub
parent 4d258d9376
commit 6ad592b1b6
4 changed files with 15 additions and 2 deletions
+1 -1
View File
@@ -296,7 +296,7 @@ class Requester:
if status == 401 and output.get("message") == "Bad credentials":
cls = GithubException.BadCredentialsException
elif status == 401 and Consts.headerOTP in headers and re.match(r'.*required.*', headers[Consts.headerOTP]):
cls = GithubException.TwoFactorException # pragma no cover (Should be covered)
cls = GithubException.TwoFactorException
elif status == 403 and output.get("message").startswith("Missing or invalid User Agent string"):
cls = GithubException.BadUserAgentException
elif status == 403 and (