Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6225265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:48:40+00:00 2026-05-24T08:48:40+00:00

I am pretty much using the samples in the SDK for my app. And

  • 0

I am pretty much using the samples in the SDK for my app. And it works great. Except I have two questions, relating to authentication.
1. How can I avoid the webform from popping up each time I start up the app? Once I have authorized my app, each time I restart it, I see the webform appear for a second and then it closes. Not very clean, in my opinion. Is there a way to check if I am still logged in, and have given my app authorization before displaying the webform?
2. If I become unauthenticated while my app is running, is there a way for me to easily detect that and then show the login form again?

I think I am close with my code below, but not quite there.

Thanks in advance!

private string[] extendedPermissions = new[] { "read_stream", "offline_access" };

public Form1()
{
    var fbLoginDialog = new FacebookLoginDialog(AppId, extendedPermissions);

    //always shows login dialog, even if the app was just recently closed. Is this necessary?
    fbLoginDialog.ShowDialog(); 

    //every minute look for new posts
    clockTimer.Elapsed += new System.Timers.ElapsedEventHandler(clockTimer_Elapsed); 

    DisplayAppropriateMessage(fbLoginDialog.FacebookOAuthResult);
    GetAllData(unixTimeOfNewestPost);
    InitializeComponent();
}

private void DisplayAppropriateMessage(FacebookOAuthResult facebookOAuthResult)
{
  if (facebookOAuthResult != null)
  {
    if (facebookOAuthResult.IsSuccess)
    {
      _accessToken = facebookOAuthResult.AccessToken;
    }
    else
    {
      MessageBox.Show(facebookOAuthResult.ErrorDescription);
    }
  }
}

private void GetAllData(double unixTs)
{
  var fb = new FacebookClient(_accessToken);
  Facebook.JsonArray posts = new JsonArray();
  try
  {
      var result = (IDictionary<string, object>)fb.Get("/me/home?since=" + unixTs + "&limit=1000");
      posts = (Facebook.JsonArray)result["data"];
  }
  catch (FacebookOAuthException e)
  {
    MessageBox.Show("FacebookOAuthException", 
      "Facebook Authorization problem. The error message was '" + e.Message + "'.", null, "");
    //show the login form again???
  }
  catch (Exception e)
  {
      Log("Exception. There was a general exception. The error message was '" + e.Message + "'.");
  }

  foreach (Facebook.JsonObject post in posts)
  {
    // do stuff with each post
  }
} // end of GetPosts()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:48:41+00:00Added an answer on May 24, 2026 at 8:48 am

    1.How can I avoid the webform from popping up each time I start up the app? Once I have authorized my app, each time I restart it, I see the webform appear for a second and then it closes. Not very clean, in my opinion. Is there a way to check if I am still logged in, and have given my app authorization before displaying the webform?

    You will need to save the access token safely somewhere else. Incase you have that access token you don’t need to even ask for the login dialog.

    2.If I become unauthenticated while my app is running, is there a way for me to easily detect that and then show the login form again?

    You will need to catch FacebookOAuthException to every requests you make and then ask the user to login

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pretty much new to using SQL Server 2000. I have been using
I have a very simple Core Data app which pretty much contains strings of
Currently i'm using pretty much Unix + Mysql + Perl + Apache with some
pretty much what the title says. I am using an Ajax Drop Down as
This is pretty much a duplicate question but instead of using Castle Dynamic Proxy
The title pretty much says it all. I'm using a TClientDataset to store an
I'm writing a smallish web service in Ruby using Sinatra. Access to pretty much
Pretty much what the title says really. We have some code that is .NET
Pretty much what the question says. What's the difference between the two classes of
I am using an example from WordNik samples-sdk, I killed most memory leaks but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.