static private GetClient ( IHiDriveAuthenticator authenticator ) : IHiDriveClient | ||
authenticator | IHiDriveAuthenticator | |
return | IHiDriveClient |
public async Task <AccountConfiguration> CreateAccount_Oidc() { var f = new OidcWaitForm(); f.InitEx(StorageType.HiDrive); f.Show(); var browser = new OidcSystemBrowser(Enumerable.Range(50001, 50020)); var redirectUri = browser.RedirectUri; var uri = _authenticator.GetAuthorizationCodeRequestUrl(new AuthorizationScope(AuthorizationRole.User, AuthorizationPermission.ReadWrite), redirectUri); var query = await browser.GetQueryStringAsync(uri.ToString(), f.CancellationToken); var code = query["code"]; var token = await _authenticator.AuthenticateByAuthorizationCodeAsync(code); var client = HiDriveHelper.GetClient(_authenticator); var user = await client.User.Me.Get().ExecuteAsync(); var account = new AccountConfiguration() { Type = StorageType.HiDrive, Id = user.Account, Name = user.Alias, Secret = _authenticator.Token.RefreshToken, }; f.Close(); return(account); }
public async Task <AccountConfiguration> CreateAccount() { var isOk = OAuth2Flow.TryAuthenticate(this); if (!isOk) { return(null); } var client = HiDriveHelper.GetClient(_authenticator); //var fields = new[] //{ // User.Fields.Account, User.Fields.Alias, User.Fields.Description, User.Fields.Protocols, User.Fields.IsAdmin, // User.Fields.EMail, User.Fields.IsEncrypted, User.Fields.Home, User.Fields.HomeId, User.Fields.IsOwner, User.Fields.Language, //}; var user = await client.User.Me.Get().ExecuteAsync(); var account = new AccountConfiguration() { Type = StorageType.HiDrive, Id = user.Account, Name = user.Alias, Secret = _authenticator.Token.RefreshToken, }; return(account); }
private async Task <IHiDriveClient> GetApi() { if (_api == null) { _api = await HiDriveHelper.GetClient(account); } return(_api); }