@@ -30,22 +30,29 @@ public EnterpriseCapabilitiesService(
3030
3131 public async Task < EnterpriseLoginMethods > ProbeLoginMethods ( Uri enterpriseBaseUrl )
3232 {
33- // It's important that we don't use our cached credentials on this connection, as they
34- // may be wrong - we're trying to log in after all.
35- var hostAddress = HostAddress . Create ( enterpriseBaseUrl ) ;
36- var connection = new Octokit . Connection ( program . ProductHeader , hostAddress . ApiUri ) ;
37- var meta = await GetMetadata ( connection ) . ConfigureAwait ( false ) ;
38- var result = EnterpriseLoginMethods . Token ;
33+ try
34+ {
35+ // It's important that we don't use our cached credentials on this connection, as they
36+ // may be wrong - we're trying to log in after all.
37+ var hostAddress = HostAddress . Create ( enterpriseBaseUrl ) ;
38+ var connection = new Octokit . Connection ( program . ProductHeader , hostAddress . ApiUri ) ;
39+ var meta = await GetMetadata ( connection ) . ConfigureAwait ( false ) ;
40+ var result = EnterpriseLoginMethods . Token ;
41+
42+ if ( meta . VerifiablePasswordAuthentication != false ) result |= EnterpriseLoginMethods . UsernameAndPassword ;
3943
40- if ( meta . VerifiablePasswordAuthentication ) result |= EnterpriseLoginMethods . UsernameAndPassword ;
44+ if ( meta . InstalledVersion != null )
45+ {
46+ var version = new Version ( meta . InstalledVersion ) ;
47+ if ( version >= MinimumOAuthVersion ) result |= EnterpriseLoginMethods . OAuth ;
48+ }
4149
42- if ( meta . InstalledVersion != null )
50+ return result ;
51+ }
52+ catch
4353 {
44- var version = new Version ( meta . InstalledVersion ) ;
45- if ( version >= MinimumOAuthVersion ) result |= EnterpriseLoginMethods . OAuth ;
54+ return EnterpriseLoginMethods . Token | EnterpriseLoginMethods . UsernameAndPassword ;
4655 }
47-
48- return result ;
4956 }
5057
5158 private async Task < EnterpriseMeta > GetMetadata ( IConnection connection )
@@ -56,9 +63,10 @@ private async Task<EnterpriseMeta> GetMetadata(IConnection connection)
5663 }
5764
5865 [ SuppressMessage ( "Microsoft.Performance" , "CA1812:AvoidUninstantiatedInternalClasses" , Justification = "Created via Octokit reflection" ) ]
59- class EnterpriseMeta : Meta
66+ class EnterpriseMeta
6067 {
6168 public string InstalledVersion { get ; private set ; }
69+ public bool ? VerifiablePasswordAuthentication { get ; private set ; }
6270 }
6371 }
6472}
0 commit comments