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

3

5

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.

Chaperon answered 9/12, 2012 at 15:16 Comment(3)
how did you solve this?Kesha
@JoãoNunes to be honest I don't remember. probably I've ended up using the Facebook SDK.Mohr
@CanPoyrazoğlu hm.. did the same after 2hours lolKesha
P
9

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.

Phonemic answered 20/10, 2013 at 3:5 Comment(1)
This is bit crazy but that was it. any problem if I have ACAccountStore as a property? After I set it as property, it worked perfectly. Thanks @PhonemicHandiwork
P
0

Try running on an actual device instead of a simulator. This worked for me.

Pharmaceutical answered 1/6, 2013 at 18:44 Comment(0)
H
0

Ensure that your bundle id is input into your Facebook app's configuration. You might have a different bundle id for your dev/debug build.

Homage answered 3/7, 2013 at 3:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.