public async Task <bool> Claim(Uri uri, string documentTitle) { //_token = HubiCHelper.GetAccessTokenFromFragment(uri); string code = null; foreach (var pair in uri.Query.TrimStart('?').Split('&')) { var elements = pair.Split('='); if (elements.Length != 2) { continue; } switch (elements[0]) { case "code": code = Uri.UnescapeDataString(elements[1]); break; } } if (code == null) { return(false); } _token = await HubiCHelper.ProcessCodeFlowAsync(code); return(_token != null); }
protected async Task <SwiftClient> GetClient() { if (_client != null) { return(_client); } var token = await HubiCHelper.GetAccessTokenAsync(_account.Secret); var credentials = await HubiCHelper.GetCredentialsAsync(token.AccessToken); _client = new SwiftClient(credentials); return(_client); }
public async Task <AccountConfiguration> CreateAccount() { var isOk = OAuth2Flow.TryAuthenticate(this); if (!isOk) { return(null); } var hubicAccount = await HubiCHelper.GetAccountAsync(_token.AccessToken); var account = new AccountConfiguration() { Type = StorageType.HubiC, Id = hubicAccount.EMail, Name = string.Format("{0} {1}", hubicAccount.FirstName, hubicAccount.LastName), Secret = _token.RefreshToken, }; return(account); }
public async Task Initialize() { this.AuthorizationUrl = HubiCHelper.GetAuthorizationUri(); this.RedirectionUrl = new Uri(HubiCHelper.RedirectUri); }