Exemplo n.º 1
0
        private async void RequestAuthorization()
        {
            ////GET FROB
            //flickr.AuthGetFrobAsync(new Action<FlickrNet.FlickrResult<string>>(x=>{

            //    if (x.Result != null)
            //    {
            //        frob = x.Result;

            //        //USE FROB TO GET URL FOR USER AUTHENTICATION
            //        string url = flickr.AuthCalcUrl(frob, FlickrNet.AuthLevel.Write);
            //        Windows.System.Launcher.LaunchDefaultProgram(new Uri(url));

            //        Dispatcher.Invoke(Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.InvokedHandler((r,a) => {
            //            butRequestAuthorization.IsEnabled = false;
            //            butAuthorizationGiven.IsEnabled = true;
            //        }), this, null);

            //    }
            //}));


            //1. GET THE OAUTH REQUEST TOKEN
            //2. CONSTRUCT A URL & LAUNCH IT TO GET AN "AUTHORIZATION" TOKEN
            await _flickr.OAuthGetRequestTokenAsync("oob", async (x) =>  //{} new Action<FlickrResult<OAuthRequestToken>>(x =>
            {
                if (!x.HasError)
                {
                    rt         = x.Result;
                    string url = _flickr.OAuthCalculateAuthorizationUrl(rt.Token, FlickrNet.AuthLevel.Write);
                    try
                    {
                        await Windows.System.Launcher.LaunchUriAsync(new Uri(url), new Windows.System.LauncherOptions()
                        {
                            DisplayApplicationPicker = true
                        });

                        Dispatcher.RunAsync(
                            Windows.UI.Core.CoreDispatcherPriority.High,
                            new Windows.UI.Core.DispatchedHandler(() =>
                        {
                            butLoginRequest.Visibility = Visibility.Collapsed;
                            butLoginConfirm.Visibility = Visibility.Visible;
                            //butRequestAuthorization.IsEnabled = false;
                            //butAuthorizationGiven.IsEnabled = true;
                            //txtOAuthVerificationCode.IsEnabled = true;
                        })
                            );
                    }
                    catch (Exception ex)
                    {
                        var m = ex.Message;
                    }
                }
                ;
            });
        }