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;
}