77using System . Reactive . Linq ;
88using System . Security . Cryptography ;
99using System . Text ;
10+ using GitHub . Extensions ;
11+ using GitHub . Logging ;
1012using GitHub . Primitives ;
1113using Octokit ;
1214using Octokit . Reactive ;
13- using ReactiveUI ;
14- using System . Threading . Tasks ;
15- using System . Reactive . Threading . Tasks ;
16- using Octokit . Internal ;
17- using System . Collections . Generic ;
18- using GitHub . Models ;
19- using GitHub . Extensions ;
20- using GitHub . Logging ;
2115using Serilog ;
2216
2317namespace GitHub . Api
@@ -29,11 +23,6 @@ public partial class ApiClient : IApiClient
2923 static readonly ILogger log = LogManager . ForContext < ApiClient > ( ) ;
3024
3125 readonly IObservableGitHubClient gitHubClient ;
32- // There are two sets of authorization scopes, old and new:
33- // The old scopes must be used by older versions of Enterprise that don't support the new scopes:
34- readonly string [ ] oldAuthorizationScopes = { "user" , "repo" , "gist" } ;
35- // These new scopes include write:public_key, which allows us to add public SSH keys to an account:
36- readonly string [ ] newAuthorizationScopes = { "user" , "repo" , "gist" , "write:public_key" } ;
3726 readonly static Lazy < string > lazyNote = new Lazy < string > ( ( ) => ProductName + " on " + GetMachineNameSafe ( ) ) ;
3827 readonly static Lazy < string > lazyFingerprint = new Lazy < string > ( GetFingerprint ) ;
3928
@@ -101,42 +90,6 @@ public IObservable<User> GetUser()
10190 return gitHubClient . User . Current ( ) ;
10291 }
10392
104- public IObservable < ApplicationAuthorization > GetOrCreateApplicationAuthenticationCode (
105- Func < TwoFactorAuthorizationException , IObservable < TwoFactorChallengeResult > > twoFactorChallengeHander ,
106- string authenticationCode = null ,
107- bool useOldScopes = false ,
108- bool useFingerPrint = true )
109- {
110- var newAuthorization = new NewAuthorization
111- {
112- Scopes = useOldScopes
113- ? oldAuthorizationScopes
114- : newAuthorizationScopes ,
115- Note = lazyNote . Value ,
116- Fingerprint = useFingerPrint ? lazyFingerprint . Value : null
117- } ;
118-
119- Func < TwoFactorAuthorizationException , IObservable < TwoFactorChallengeResult > > dispatchedHandler =
120- ex => Observable . Start ( ( ) => twoFactorChallengeHander ( ex ) , RxApp . MainThreadScheduler ) . Merge ( ) ;
121-
122- var authorizationsClient = gitHubClient . Authorization ;
123-
124- return string . IsNullOrEmpty ( authenticationCode )
125- ? authorizationsClient . CreateAndDeleteExistingApplicationAuthorization (
126- ClientId ,
127- ClientSecret ,
128- newAuthorization ,
129- dispatchedHandler ,
130- true )
131- : authorizationsClient . CreateAndDeleteExistingApplicationAuthorization (
132- ClientId ,
133- ClientSecret ,
134- newAuthorization ,
135- dispatchedHandler ,
136- authenticationCode ,
137- true ) ;
138- }
139-
14093 public IObservable < Organization > GetOrganizations ( )
14194 {
14295 // Organization.GetAllForCurrent doesn't return all of the information we need (we
0 commit comments