Search code examples
objective-cios6ios7facebook-access-token

Facebook Access Token: (null) with Social.framework iOS


I've scoured posts regarding this topic, I'm new to the Social.framework/Facebook SDK in iOS. I have followed an example similar to How to use iOS 6's social framework

I set up an app in Facebook and enabled FB login. My JSON error being (as well as when I go to https://graph.facebook.com/):

error =     {
    code = 104;
    message = "An access token is required to request this resource.";
    type = OAuthException;
};

and even tried accessing the token via (which gives me null):

    // Get the access token, could be used in other scenarios
    ACAccountCredential *fbCredential = [account credential];
    NSString *accessToken = [fbCredential oauthToken];
    NSLog(@"Facebook Access Token: %@", accessToken);

When the user starts the app, it immediately jumps to the authorization of facebook data, they press OK to continue. Simple. I've read up on Access Tokens here.

My question, doesn't the access token get instantiated upon the user hitting OK? Or do I set it up somewhere in the App page on developers.facebook.com? I'm a novice with the Facebook integration and am royally confused on how to solve this problem.

Thanks for your help.


Solution

  • The problem was: A) the Bundle ID in the developers.facebook.com did not match the Bundle ID in the project, and B) the URL used was

    NSURL *url = [NSURL URLWithString:@"http://graph.facebook.com/search"]; 
    

    and not

    NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/search"];
    

    I hope many can benefit from my sorrows :)