Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit f7a726a

Browse files
committed
github: conditionally append OTP header
Only append the "X-GitHub-OTP" header if there's a value to append with it. Including the header without a value appears cause github.com to emit 2FA SMS messages.
1 parent 1420d21 commit f7a726a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

GitHub.Authentication/Src/Authority.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ public async Task<AuthenticationResult> AcquireToken(
8686
};
8787

8888
options.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(GitHubApiAcceptsHeaderValue));
89-
options.Headers.Add(GitHubOptHeader, authenticationCode);
89+
90+
if (!string.IsNullOrWhiteSpace(authenticationCode))
91+
{
92+
options.Headers.Add(GitHubOptHeader, authenticationCode);
93+
}
9094

9195
// Create the authority Uri.
9296
var requestUri = targetUri.CreateWith(_authorityUrl);

0 commit comments

Comments
 (0)