private async Task <AmazonDrive> Authenticate(CancellationToken cs, bool interactiveAuth = true) { var settings = Gui.Properties.Settings.Default; var amazon = new AmazonDrive(AmazonSecret.ClientId, AmazonSecret.ClientSecret); amazon.OnTokenUpdate = this; if (!string.IsNullOrWhiteSpace(settings.AuthRenewToken)) { if (await amazon.AuthenticationByTokens( settings.AuthToken, settings.AuthRenewToken, settings.AuthTokenExpiration)) { return(amazon); } } if (interactiveAuth) { if (await amazon.AuthenticationByExternalBrowser(CloudDriveScopes.ReadAll | CloudDriveScopes.Write, TimeSpan.FromMinutes(10), cs, "http://localhost:{0}/signin/")) { return(amazon); } } cs.ThrowIfCancellationRequested(); return(null); }
protected async Task <AmazonDrive> Authenticate() { var settings = Properties.Settings.Default; // AmazonSecret is in git ignore because Amazon App info should not be public. // So to run tests you need to create your own class with your App Id and Secret. var amazon = new AmazonDrive(AmazonSecret.ClientId, AmazonSecret.ClientSecret); amazon.OnTokenUpdate = this; if (!string.IsNullOrWhiteSpace(settings.AuthRenewToken)) { if (await amazon.AuthenticationByTokens( settings.AuthToken, settings.AuthRenewToken, settings.AuthTokenExpiration)) { return(amazon); } } if (await amazon.AuthenticationByExternalBrowser(CloudDriveScopes.ReadAll | CloudDriveScopes.Write | CloudDriveScopes.Profile, TimeSpan.FromMinutes(10))) { return(amazon); } return(null); }
protected async Task <AmazonDrive> Authenticate() { var settings = Properties.Settings.Default; var amazon = new AmazonDrive(AmazonSecret.ClientId, AmazonSecret.ClientSecret); amazon.OnTokenUpdate = this; if (!string.IsNullOrWhiteSpace(settings.AuthRenewToken)) { if (await amazon.AuthenticationByTokens( settings.AuthToken, settings.AuthRenewToken, settings.AuthTokenExpiration)) { return(amazon); } } if (await amazon.AuthenticationByExternalBrowser(CloudDriveScopes.ReadAll | CloudDriveScopes.Write, TimeSpan.FromMinutes(10))) { return(amazon); } return(null); }
protected async Task<AmazonDrive> Authenticate() { var settings = Properties.Settings.Default; // AmazonSecret is in git ignore because Amazon App info should not be public. // So to run tests you need to create your own class with your App Id and Secret. var amazon = new AmazonDrive(AmazonSecret.ClientId, AmazonSecret.ClientSecret); amazon.OnTokenUpdate = this; if (!string.IsNullOrWhiteSpace(settings.AuthRenewToken)) { if (await amazon.AuthenticationByTokens( settings.AuthToken, settings.AuthRenewToken, settings.AuthTokenExpiration)) { return amazon; } } if (await amazon.AuthenticationByExternalBrowser(CloudDriveScopes.ReadAll | CloudDriveScopes.Write | CloudDriveScopes.Profile, TimeSpan.FromMinutes(10))) { return amazon; } return null; }