From 9f49854033bb408f684be86029d9d17fb24ca989 Mon Sep 17 00:00:00 2001 From: Kevin Harrington Date: Wed, 13 Nov 2019 00:17:57 -0500 Subject: [PATCH] Comments for the path of OTP exception --- src/main/java/org/kohsuke/github/Requester.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/Requester.java b/src/main/java/org/kohsuke/github/Requester.java index c96173f71..ddcef80a9 100644 --- a/src/main/java/org/kohsuke/github/Requester.java +++ b/src/main/java/org/kohsuke/github/Requester.java @@ -758,7 +758,9 @@ class Requester { IOUtils.closeQuietly(es); } } - if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) // 401 Unauthorized == bad creds + if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) // 401 Unauthorized == bad creds or OTP request + // In the case of a user with 2fa enabled, a header with X-GitHub-OTP + // will be returned indicating the user needs to respond with an otp if(uc.getHeaderField("X-GitHub-OTP") != null) throw (IOException) new GHOTPRequiredException().withResponseHeaderFields(uc).initCause(e); else