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 8809195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:48:39+00:00 2026-06-14T02:48:39+00:00

Nothing I’m reading (many FB dev articles and SO question) is helping, so I

  • 0

Nothing I’m reading (many FB dev articles and SO question) is helping, so I thought I’d post here. I’m trying to get this all to work with iOS 6 and Facebook SDK 3.1.1.

I’ve got a pretty basic setup: My iOS app authenticates with Facebook, I pass the access_token to my server and the user is now logged into my app. The only other thing they can do related to facebook is post something to their wall. I’m using the legacy Dialog window so the user can add their own comments.

Everything works perfectly on a new install for the first hour or so. If the user is logged in via the iOS Settings app, they’re presented with a quick iOS confirmation box, I get their token, send it to my server and we’re all good.

If I paste the token I receive into Facebook’s Access Token debugger, it shows that it will expire in an hour.

If I wait that hour and come back to the app afterwards, anything I try to do gives me this error:

{"error_code":190,"
  error_msg":"Error validating access token: 
              Session has expired at unix time 1351497600. 
              The current unix time is 1351525180. }
  1. What do I need to do so things just work? I’ve read that in SDK 3.1.1 FBSession will just take care of it, but that doesn’t seem like the case. My access token is expiring, and once it does, iOS/FB SDK won’t give me back a refreshed one.
  2. Even logging out (which calls [FBSession.activeSession closeAndClearTokenInformation]) doesn’t fix this. The only thing I’ve been able to do is “Reset Content and Settings” in the iOS Simulator Preferences, re-enter my FB credentials in Settings.app, and rebuild my app. Only then can I get another token which will expire in an hour.

Random notes:

  1. When my app resumes, I’m calling [FBSession.activeSession handleDidBecomeActive] and [self.facebook extendAccessTokenIfNeeded]
  2. According to the SO question linked to above, the SDK should automatically be calling FBSession#renewSystemAuthorization. I’ve put an NSLog in there, and I never see that method getting called.

UPDATE #1:

I mentioned that I’ve read that the SDK will handle invalid/expired tokens. It seems like that should happen in FBRequestConnection#completeWithResults:orError:. See inline comments for notes about the code path.

- (void)completeWithResults:(NSArray *)results
                orError:(NSError *)error
{
    int count = [self.requests count];
    for (int i = 0; i < count; i++) {
        FBRequestMetadata *metadata = [self.requests objectAtIndex:i];
        id result = error ? nil : [results objectAtIndex:i];
        NSError *itemError = error ? error : [self errorFromResult:result];

        id body = nil;
        if (!itemError && [result isKindOfClass:[NSDictionary class]]) {
            NSDictionary *resultDictionary = (NSDictionary *)result;
            body = [FBGraphObject graphObjectWrappingDictionary:[resultDictionary objectForKey:@"body"]];
        }

        ...

        // *******************************************
        // My code actually falls into this block, proving that I do in fact have an invalid session
        // *******************************************
        if ([self isInvalidSessionError:itemError
                        resultIndex:error == itemError ? i : 0]) {
            [metadata.request.session closeAndClearTokenInformation:itemError];

            // *******************************************
            // Unfortunately metadata.request.session is nil, so this condition is never
            // run, so renewySystemAuthorization is never called
            // *******************************************
            if (metadata.request.session.loginType == FBSessionLoginTypeSystemAccount){
                [FBSession renewSystemAuthorization];
        }
    }

    ...
}
  • 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-06-14T02:48:40+00:00Added an answer on June 14, 2026 at 2:48 am

    This isn’t the type of fix I was after, but things look to be working as expected, so at this point I just need to ship.

    First things first, it turns out that old versions of our app were requesting offline_access. I did not know that. I went in to my FB app’s Settings > Advanced, and enabled “Remove offline_access permission.” I am now getting back a token that lasts two months (check out the facbeook token debugger).

    Now that I’m getting back the correct kind of token, I still have a problem with getting back a valid token when it has been deactivated/expired. Since I’m now getting back a 2 month token, I can’t wait for that to expire, so my plan was to trigger an OAuthException by going into my account’s settings and deauthorizing it.

    In my appDidBecomeActive, I put [FBRequestConnection startForMeWithCompletionHandler:nil] to simply trigger a silent request to FB, and when that fails because of an invalid session/token, the code flow runs through the correct path and [FBSession renewSystemAuthorization] ends up getting called, which is ultimately what I was needing. What this allows iOS to do is the next time I go to Log in to my app through FB, iOS prompts me again, understanding I don’t have a valid token anymore. Calling [FBSession renewSystemAuthorization] effectively tells iOS that the next time my app requests access, hit facebook and give me back a new/refreshed token.

    For the most part everything is working as expected now.

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

Sidebar

Related Questions

Note: this question has nothing to do with Knockout.js, but it's about the selectedOptions
There's nothing here because the question fit into the title field.
I know nearly nothing about this all so I turn to you for some
{This has nothing to do with Twitter} Bit of an interesting question, interesting in
I see nothing documented on this, so does anyone know if it is possible
XPath returns nothing if a child element has no text value. In this case,
All my searches returned nothing and I find it odd that there aren't any
I'm getting a nothing to repeat error when I try to compile this: search
Nothing technical here. Suppose I have a lot of different categorized data, and I
Nothing I've tried can get my code to submit correctly. Can anyone else figure

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.