Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ACAccount Facebook: An active access token must be used to query information about the current user

I am using iOS 6 Social framework for accessing user's Facebook data. I am trying to get likes of the current user within my app using ACAccount and SLRequest. I have a valid Facebook account reference of type ACAccount named facebook, and I'm trying to get user's likes this way:

SLRequest *req = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodGET URL:url parameters:nil];
req.account = facebook;
[req performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
     //my handler code.
}

where url is @"https://graph.facebook.com/me/likes?fields=name"; In my handler, I'm getting this response:

{
error =     {
    code = 2500;
    message = "An active access token must be used to query information about the current user.";
    type = OAuthException;
};
}

Shouldn't access tokens be handled by the framework? I've found a similar post Querying Facebook user data through new iOS6 social framework but it doesn't make sense to hard-code an access token parameter into the URL, as logically the access token/login checking should be handled automatically by the framework. In all examples that I've seen around no one plays with an access token manually:

http://damir.me/posts/facebook-authentication-in-ios-6

iOS 6 Facebook posting procedure ends up with "remote_app_id does not match stored id" error etc.

I am using the iOS6-only approach with the built in Social framework, and I'm not using the Facebook SDK. Am I missing something?

Thanks,

Can.

like image 600
Can Poyrazoğlu Avatar asked Dec 09 '12 15:12

Can Poyrazoğlu


1 Answers

You need to keep a strong reference to the ACAccountStore that the account comes from. If the store gets deallocated, it looks like it causes this problem.

like image 100
Ethan Avatar answered Sep 28 '22 10:09

Ethan