コード例 #1
0
        public async Task <ActionResult> About()
        {
            ViewBag.Message = "Your app description page.";

            string verifier = Request.QueryString["oauth_verifier"];

            if (!string.IsNullOrEmpty(verifier))
            {
                Authentication.CopyAuth copyConfig = (Authentication.CopyAuth)Session["copyConfig"];

                CopyClient copyClient = await copyConfig.GetAccessTokenAsync(verifier);

                Session.Add("copyClient", copyClient);

                FileSystem rootFolder = await copyClient.GetRootFolder();
            }
            else if (Session["copyClient"] != null)
            {
                //CopyClient copyClient = (CopyClient) Session["copyClient"];

                //FileSystem rootFolder = await copyClient.GetRootFolder();
            }

            return(View());
        }
コード例 #2
0
        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
        private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            if (_appSettings.Contains("authenticated"))
            {
                Oauth.Visibility       = Visibility.Collapsed;
                UserDetails.Visibility = Visibility.Visible;
            }
            else
            {
                Oauth.VerifiedCodeReceived += async(s, ec) =>
                {
                    OAuth2Sample auth = s as OAuth2Sample;
                    if (auth != null)
                    {
                        copyClient = await copyConfig.GetAccessTokenAsync(auth.VerifierCode);

                        Dispatcher.BeginInvoke(new Action <CopyClient>(AfterAuthenticate), copyClient);
                    }
                };

                Scope scope = new Scope()
                {
                    Profile = new ProfilePermission()
                    {
                        Read  = true,
                        Write = true
                    }
                };

                copyConfig = new Authentication.CopyAuth("http://copysdk", "cIAKv1kFCwXn2izGsMl8vZmfpfBcJSv1", "vNY1oLTr2WieLYxgCA6tDgdfCS1zTRA2IMzhmQLoQOS7nmIK", scope);

                await copyConfig.GetRequestTokenAsync();

                Oauth.Visibility           = Visibility.Visible;
                AuthenticateBtn.Visibility = Visibility.Collapsed;

                Oauth.GetVerifierCode(copyConfig.AuthCodeUri, new Uri(copyConfig.CallbackURL));
            }
        }
コード例 #3
0
        public async Task <ActionResult> Authenticate()
        {
            Scope scope = new Scope()
            {
                Profile = new ProfilePermission()
                {
                    Read  = true,
                    Write = true
                },
                FileSystem = new FileSystemPermission()
                {
                    Read  = true,
                    Write = true
                }
            };

            Authentication.CopyAuth copyConfig = new Authentication.CopyAuth("http://localhost/CopyMVC/Home/About", "cIAKv1kFCwXn2izGsMl8vZmfpfBcJSv1", "vNY1oLTr2WieLYxgCA6tDgdfCS1zTRA2IMzhmQLoQOS7nmIK", scope);

            await copyConfig.GetRequestTokenAsync();

            Session.Add("copyConfig", copyConfig);

            return(Redirect(copyConfig.AuthCodeUri.AbsoluteUri));
        }
コード例 #4
0
        public async Task<ActionResult> Authenticate()
        {
            Scope scope = new Scope()
            {
                Profile = new ProfilePermission()
                {
                    Read = true,
                    Write = true
                },
                FileSystem = new FileSystemPermission()
                {
                    Read = true,
                    Write = true
                }
            };

            Authentication.CopyAuth copyConfig = new Authentication.CopyAuth("http://localhost/CopyMVC/Home/About", "cIAKv1kFCwXn2izGsMl8vZmfpfBcJSv1", "vNY1oLTr2WieLYxgCA6tDgdfCS1zTRA2IMzhmQLoQOS7nmIK", scope);

            await copyConfig.GetRequestTokenAsync();

            Session.Add("copyConfig", copyConfig);

            return Redirect(copyConfig.AuthCodeUri.AbsoluteUri);
        }
コード例 #5
0
        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
        private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            if (_appSettings.Contains("authenticated"))
            {
                Oauth.Visibility = Visibility.Collapsed;
                UserDetails.Visibility = Visibility.Visible;
            }
            else
            {
                Oauth.VerifiedCodeReceived += async (s, ec) =>
                {
                    OAuth2Sample auth = s as OAuth2Sample;
                    if (auth != null)
                    {                        
                        copyClient = await copyConfig.GetAccessTokenAsync(auth.VerifierCode);                        

                        Dispatcher.BeginInvoke(new Action<CopyClient>(AfterAuthenticate), copyClient);
                    }
                };

                Scope scope = new Scope()
                {
                    Profile = new ProfilePermission()
                    {
                        Read = true,
                        Write = true
                    }
                };

                copyConfig = new Authentication.CopyAuth("http://copysdk", "cIAKv1kFCwXn2izGsMl8vZmfpfBcJSv1", "vNY1oLTr2WieLYxgCA6tDgdfCS1zTRA2IMzhmQLoQOS7nmIK", scope);

                await copyConfig.GetRequestTokenAsync();

                Oauth.Visibility = Visibility.Visible;
                AuthenticateBtn.Visibility = Visibility.Collapsed;

                Oauth.GetVerifierCode(copyConfig.AuthCodeUri, new Uri(copyConfig.CallbackURL));
            }
        }