Invalid Frob

Topics: Developer Forum, User Forum
Jul 31, 2011 at 5:17 PM

I m trying to navigate to next page before I obtain the authentication token during  which I m getting an message saying" invalid frob ". If I get authentication token after sign in with yahoo credentials and navigate to next page "Invalid Frob" does not appear. 

When I m trying to navigate to next page before obtaining the authentication token I want to inform the user with some meaningful message such as "Authenticate to Proceed" instead of invalid frob. Please let me know if it could be done .

Here goes my sample code

        void Authentication_Loaded(object sender, RoutedEventArgs e)
        { 
            // Check whether internet connection is available
            if (NetworkInterface.GetIsNetworkAvailable())
            {

                // Check if the Authentication Token Already Present 
                if (!String.IsNullOrEmpty(AppHelper.AuthenticationToken))
                {
                    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                }
                else
                {
                    App app = Application.Current as App;
                    app.Flickr.AuthGetFrobAsync(r =>
                    {
                        Dispatcher.BeginInvoke(() =>
                        {
                            if (r.HasError)
                            {
                                MessageBox.Show(r.Error.Message);
                            }
                            else
                            {
                                frob = r.Result;
                                string url = app.Flickr.AuthCalcUrl(frob, FlickrNet.AuthLevel.Write);
                                Uri uri = new Uri(url);
                                webBrowser1.Navigate(uri);
                            }
                        });
                    });
                }
            }
            else
            {
                MessageBox.Show("Internet Connection not available");
            }
        }



        private void btnSignIn_Click(object sender, RoutedEventArgs e)
        {
            // Enable Tilt effect
            TiltEffect.SetIsTiltEnabled((App.Current as App).RootFrame, true);
            
            checking = true;
            App app = Application.Current as App;
            
            if (String.IsNullOrEmpty(AppHelper.AuthenticationToken))
                {

                        app.Flickr.AuthGetTokenAsync(frob, r =>
                        {
                            Dispatcher.BeginInvoke(() =>
                            {
                                if (r.HasError)
                                {
                                    MessageBox.Show(r.Error.Message);
                                   
                                }
                                else
                                {
                                    AppHelper.AuthenticationToken = r.Result.Token;
                                    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                                }

                                checking = false;
                            });
                        });
                } // End of if
                else
                {
                    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                }

 

-Mugu

Coordinator
Aug 1, 2011 at 10:32 AM

Well you can either check r.Error to see if is a FlickrApiException and then check the FlickrApiException.Code to see if is 108 (which is the number for Invalid Frob).

Alternatively you can actually use the Web Based authentication.

Set the callback URL to a unique URL that does not actually exist (e.g. http://localhost/junk).

Then use AuthCalcWebUrl to redirect to the Flickr web site.

Then listen to the WebBrowser.Navigating event, and check the URL. If the URL matches you junk callback URL above then get the frob from the URL querystring and call AuthGetToken with that frob.

Sam