@@ -61,17 +61,6 @@ public async Task<AuthenticationPromptResult> GetAuthenticationAsync(Uri targetU
61
61
{
62
62
ThrowIfUserInteractionDisabled ( ) ;
63
63
64
- // If the GitHub auth stack doesn't support flows such as RFC 8628 and we do not have
65
- // an interactive desktop session, we cannot offer OAuth authentication.
66
- if ( ( modes & AuthenticationModes . OAuth ) != 0
67
- && ! Context . SessionManager . IsDesktopSession
68
- && ! GitHubConstants . IsOAuthDeviceAuthSupported )
69
- {
70
- Context . Trace . WriteLine ( "Ignoring OAuth authentication mode because we are not in an interactive desktop session. GitHub does not support RFC 8628." ) ;
71
-
72
- modes &= ~ AuthenticationModes . OAuth ;
73
- }
74
-
75
64
if ( modes == AuthenticationModes . None )
76
65
{
77
66
throw new ArgumentException ( $ "Must specify at least one { nameof ( AuthenticationModes ) } ", nameof ( modes ) ) ;
@@ -211,21 +200,14 @@ public async Task<OAuth2TokenResult> GetOAuthTokenAsync(Uri targetUri, IEnumerab
211
200
{
212
201
ThrowIfTerminalPromptsDisabled ( ) ;
213
202
214
- if ( GitHubConstants . IsOAuthDeviceAuthSupported )
215
- {
216
- OAuth2DeviceCodeResult deviceCodeResult = await oauthClient . GetDeviceCodeAsync ( scopes , CancellationToken . None ) ;
217
-
218
- string deviceMessage = $ "To complete authentication please visit { deviceCodeResult . VerificationUri } and enter the following code:" +
219
- Environment . NewLine +
220
- deviceCodeResult . UserCode ;
221
- Context . Terminal . WriteLine ( deviceMessage ) ;
203
+ OAuth2DeviceCodeResult deviceCodeResult = await oauthClient . GetDeviceCodeAsync ( scopes , CancellationToken . None ) ;
222
204
223
- return await oauthClient . GetTokenByDeviceCodeAsync ( deviceCodeResult , CancellationToken . None ) ;
224
- }
205
+ string deviceMessage = $ "To complete authentication please visit { deviceCodeResult . VerificationUri } and enter the following code:" +
206
+ Environment . NewLine +
207
+ deviceCodeResult . UserCode ;
208
+ Context . Terminal . WriteLine ( deviceMessage ) ;
225
209
226
- // We'd like to try using an OAuth2 flow that does not require a web browser on this device
227
- // such as the device code flow (RFC 8628) but GitHub's auth stack does not support this.
228
- throw new NotSupportedException ( "GitHub OAuth authentication is not supported without an interactive desktop session." ) ;
210
+ return await oauthClient . GetTokenByDeviceCodeAsync ( deviceCodeResult , CancellationToken . None ) ;
229
211
}
230
212
}
231
213
0 commit comments