public async Task <AccountConfiguration> CreateAccount() { _oAuthHelper = new OAuthHelper(); var isOk = OAuth2Flow.TryAuthenticate(this); if (!isOk) { return(null); } var api = await OneDriveHelper.GetApi(_accountSession); var drive = await api.Drive.Request().GetAsync().ConfigureAwait(false); var account = new AccountConfiguration { Type = StorageType.OneDrive, Name = drive.Owner.User.DisplayName, Id = drive.Owner.User.Id, Secret = _accountSession.RefreshToken }; return(account); }
/// <summary> /// Read all settings from App.config. /// </summary> /// <param name="settings">The parsed app.config settings.</param> protected virtual void ReadSettings(Hashtable settings) { // Common keys. string proxyUrl = ReadSetting(settings, PROXY_SERVER, ""); if (!string.IsNullOrEmpty(proxyUrl)) { WebProxy proxy = new WebProxy(); proxy.Address = new Uri(proxyUrl); string proxyUser = ReadSetting(settings, PROXY_USER, ""); string proxyPassword = ReadSetting(settings, PROXY_PASSWORD, ""); string proxyDomain = ReadSetting(settings, PROXY_DOMAIN, ""); if (!string.IsNullOrEmpty(proxyUrl)) { proxy.Credentials = new NetworkCredential(proxyUser, proxyPassword, proxyDomain); } this.proxy = proxy; } else { // System.Net.WebRequest will find a proxy if needed. this.proxy = null; } maskCredentials = bool.Parse(ReadSetting(settings, MASK_CREDENTIALS, maskCredentials.ToString())); try { oAuth2Mode = (OAuth2Flow)Enum.Parse(typeof(OAuth2Flow), ReadSetting(settings, OAUTH2_MODE, oAuth2Mode.ToString())); } catch (Exception e) { // No action. } oAuth2ClientId = ReadSetting(settings, OAUTH2_CLIENTID, oAuth2ClientId); oAuth2ClientSecret = ReadSetting(settings, OAUTH2_CLIENTSECRET, oAuth2ClientSecret); oAuth2AccessToken = ReadSetting(settings, OAUTH2_ACCESSTOKEN, oAuth2AccessToken); oAuth2RefreshToken = ReadSetting(settings, OAUTH2_REFRESHTOKEN, oAuth2RefreshToken); oAuth2Scope = ReadSetting(settings, OAUTH2_SCOPE, oAuth2Scope); oAuth2RedirectUri = ReadSetting(settings, OAUTH2_REDIRECTURI, oAuth2RedirectUri); oAuth2ServiceAccountEmail = ReadSetting(settings, OAUTH2_SERVICEACCOUNT_EMAIL, oAuth2ServiceAccountEmail); oAuth2PrnEmail = ReadSetting(settings, OAUTH2_PRN_EMAIL, oAuth2PrnEmail); oAuth2CertificatePath = ReadSetting(settings, OAUTH2_JWT_CERTIFICATE_PATH, oAuth2CertificatePath); oAuth2CertificatePassword = ReadSetting(settings, OAUTH2_JWT_CERTIFICATE_PASSWORD, oAuth2CertificatePassword); email = ReadSetting(settings, EMAIL, email); password = ReadSetting(settings, PASSWORD, password); authToken = ReadSetting(settings, AUTHTOKEN, authToken); int.TryParse(ReadSetting(settings, TIMEOUT, timeout.ToString()), out timeout); int.TryParse(ReadSetting(settings, RETRYCOUNT, retryCount.ToString()), out retryCount); bool.TryParse(ReadSetting(settings, ENABLE_GZIP_COMPRESSION, enableGzipCompression.ToString()), out enableGzipCompression); }
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); }
public async Task <AccountConfiguration> CreateAccount() { var isOk = OAuth2Flow.TryAuthenticate(this); if (!isOk) { return(null); } var api = await GoogleDriveHelper.GetClient(_token); var query = api.About.Get(); query.Fields = "user"; var about = await query.ExecuteAsync(); var account = new AccountConfiguration() { Type = StorageType.GoogleDrive, Id = about.User.PermissionId, Name = about.User.DisplayName, Secret = _token.RefreshToken }; return(account); }
/// <summary> /// Default constructor for the object. /// </summary> public AppConfigBase() { proxy = null; maskCredentials = true; timeout = DEFAULT_TIMEOUT; enableGzipCompression = true; oAuth2Mode = OAuth2Flow.APPLICATION; oAuth2ClientId = ""; oAuth2ClientSecret = ""; oAuth2AccessToken = ""; oAuth2RefreshToken = ""; oAuth2Scope = ""; oAuth2RedirectUri = null; oAuth2PrnEmail = ""; oAuth2ServiceAccountEmail = ""; includeFeaturesInUserAgent = true; }
/// <summary> /// Translate CogniStreamer IdentityServer OAuth2Flow to ThinkTecture IdentityServer3 Flows enum. /// </summary> /// <param name="flow">The CongniStreamer IdentityServer OAuth2Flow enumeration.</param> /// <returns>The ThinkTecture IdentityServer3 variant.</returns> private static Flows Translate(OAuth2Flow flow) { switch (flow) { case OAuth2Flow.AuthorizationCode: return Flows.AuthorizationCode; case OAuth2Flow.Implicit: return Flows.Implicit; case OAuth2Flow.Hybrid: return Flows.Hybrid; case OAuth2Flow.ClientCredentials: return Flows.ClientCredentials; case OAuth2Flow.ResourceOwner: return Flows.ResourceOwner; default: return Flows.Implicit; } }
public async Task <AccountConfiguration> CreateAccount() { var isOk = OAuth2Flow.TryAuthenticate(this); if (!isOk) { return(null); } var user = await _api.UsersManager.GetCurrentUserInformationAsync(); return(new AccountConfiguration { Type = StorageType.Box, Id = user.Id, Name = user.Name, Secret = _token.RefreshToken }); }
/// <summary> /// Default constructor for the object. /// </summary> protected AppConfigBase() { proxy = null; maskCredentials = true; timeout = DEFAULT_TIMEOUT; enableGzipCompression = true; oAuth2Mode = OAuth2Flow.APPLICATION; oAuth2ClientId = ""; oAuth2ClientSecret = ""; oAuth2AccessToken = ""; oAuth2RefreshToken = ""; oAuth2Scope = ""; oAuth2RedirectUri = null; oAuth2PrnEmail = ""; oAuth2ServiceAccountEmail = ""; authToken = ""; email = ""; password = ""; }
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 <AccountConfiguration> CreateAccount() { var isOk = OAuth2Flow.TryAuthenticate(this); if (!isOk) { return(null); } var profile = await _api.Profile.GetProfile(); var account = new AccountConfiguration() { Id = profile.user_id, Name = profile.name, Type = StorageType.AmazonDrive, Secret = _token.RefreshToken, }; return(account); }
public async Task <AccountConfiguration> CreateAccount() { var isOk = OAuth2Flow.TryAuthenticate(this); if (!isOk) { return(null); } var api = DropboxHelper.GetApi(_oauthResponse.AccessToken); var owner = await api.Users.GetCurrentAccountAsync(); var account = new AccountConfiguration() { Id = owner.AccountId, Name = owner.Name.DisplayName, Type = _isAccessRestricted ? StorageType.DropboxRestricted : StorageType.Dropbox, Secret = _oauthResponse.AccessToken, }; return(account); }
public async Task <AccountConfiguration> CreateAccount() { _api = new OneDriveConsumerApi(OneDriveHelper.OneDriveClientId, OneDriveHelper.OneDriveClientSecret); var isOk = OAuth2Flow.TryAuthenticate(this); if (!isOk) { return(null); } var drive = await _api.GetDrive(); var account = new AccountConfiguration { Type = StorageType.OneDrive, Name = drive.Owner.User.DisplayName, Id = drive.Id, Secret = _api.AccessToken.RefreshToken }; return(account); }