コード例 #1
0
ファイル: App.xaml.cs プロジェクト: wacowXD/ACDDokanNet
        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);
        }
コード例 #2
0
 public async void test()
 {
     string clientId = "amzn1.application-oa2-client.d5581ef181e7426a92dcbd1ccbb5e89c";
     string secret   = "8180ad1b1e6688f5247a94f4d7a58d4c08d1abd6df3dd4cd576990725281d91b";
     var    amazon   = new AmazonDrive(clientId, secret);
     var    result   = await amazon.AuthenticationByExternalBrowser(CloudDriveScopes.ReadAll | CloudDriveScopes.Write, TimeSpan.FromMinutes(1)).ConfigureAwait(false);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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;
        }
コード例 #6
0
        public async Task AuthenticationByExternalBrowserTest()
        {
            var amazon = new AmazonDrive(AmazonSecret.ClientId, AmazonSecret.ClientSecret);

            var result = await amazon.AuthenticationByExternalBrowser(CloudDriveScopes.ReadAll | CloudDriveScopes.Write, TimeSpan.FromMinutes(1)).ConfigureAwait(false);
            Assert.True(result);
        }
コード例 #7
0
        public async Task AuthenticationByExternalBrowserTest()
        {
            var amazon = new AmazonDrive(AmazonSecret.ClientId, AmazonSecret.ClientSecret);

            var result = await amazon.AuthenticationByExternalBrowser(CloudDriveScopes.ReadAll | CloudDriveScopes.Write, TimeSpan.FromMinutes(1)).ConfigureAwait(false);

            Assert.True(result);
        }
コード例 #8
0
        /// <summary>
        /// TODO
        /// </summary>
        /// <param name="cs"></param>
        /// <param name="interactiveAuth"></param>
        /// <returns></returns>
        public async Task <AmazonDrive> Authenticate(CancellationToken cs, bool interactiveAuth = true)
        {
            var Settings = ACDSettings.Default;

            if (Settings.AuthToken != null)
            {
                Authenticated = true;
                var token = new AuthToken();
                token.access_token = Settings.AuthToken;
                amazon             = new AmazonDrive(Settings.ClientId, Settings.ClientSecret, token);
                return(amazon);
            }

            amazon = new AmazonDrive(Settings.ClientId, Settings.ClientSecret);
            amazon.OnTokenUpdate = this;

            if (await amazon.AuthenticationByExternalBrowser(TimeSpan.FromMinutes(2), cs, "http://localhost:{0}/signin/"))
            {
                Authenticated = true;
                return(amazon);
            }

            return(null);
        }