I have been searching Google and SO and cannot find what com.apple.accounts Error Code 8 means. I am attempting to use iOS 6 and the Facebook SDK.
I run this request;
if (!_accountStore) _accountStore = [[ACAccountStore alloc] init];
ACAccountType *fbActType = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:
(NSString *)ACFacebookAppIdKey, @"###############",
(NSString *)ACFacebookPermissionsKey, [NSArray arrayWithObject:@"email"],
nil];
[_accountStore requestAccessToAccountsWithType:fbActType options:options completion:^(BOOL granted, NSError *error) {
if (granted) {
NSLog(@"Success");
NSArray *accounts = [_accountStore accountsWithAccountType:fbActType];
_facebookAccount = [accounts lastObject];
} else {
NSLog(@"ERR: %@",error);
// Fail gracefully...
}
}
];
I get this error:
ERR: Error Domain=com.apple.accounts Code=8 "The operation couldn’t be completed. (com.apple.accounts error 8.)"
No matter what I do, granted
never returns true. Any ideas would be very much appreciated.
If I bypass the if(granted)
and call this function:
- (void)me{
NSLog(@"Home.m - (void)me");
NSURL *meurl = [NSURL URLWithString:@"https://graph.facebook.com/me"];
SLRequest *merequest = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:meurl
parameters:nil];
merequest.account = _facebookAccount;
[merequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *meDataString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"%@", meDataString);
}];
Then I see this JSON that is returned by Facebook:
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}}
Update: So, the error means "The client's access info dictionary has incorrect or missing values." but I do not know what that means.
There is an error in your options dictionary.
NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:
(NSString *)ACFacebookAppIdKey, @"###############",
(NSString *)ACFacebookPermissionsKey, [NSArray arrayWithObject:@"email"],
nil];
read better the method declaration: "dictionary with object and keys", so first object, then key...but you have inserted first KEYS and then OBJECTS (wrong order :-)
The correct dictionary is:
NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:
@"###############", ACFacebookAppIdKey,
[NSArray arrayWithObject:@"email"], ACFacebookPermissionsKey,
nil];
or, declaring dictionary literal:
NSDictionary *options = @{
ACFacebookAppIdKey : @"###############",
ACFacebookPermissionsKey : [NSArray arrayWithObject:@"email"]
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With