Search code examples
objective-cfacebookmacosacaccountacaccountstore

OSX ACAccountStore requestAccessToAccountsWithType... returning 'granted=No' and error=nil after denying permissions


I am trying to request access to my facebook account. The first time I ran this it went well and I saw the popup requesting permissions. The popup asked me to allow or deny. I chose to deny because I wanted to test that use case. Now I cannot figure out how to get it to allow access again. I have deleted the app from my facebook account and deleted my facebook account from my mac. I've also tried adding the property

@"auth_type": @"rerequest"

to the options dictionary. I get the same result no matter what.

As mentioned in the title, the error is nil and granted is False.

Thanks in advance.

ACAccountType* accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

NSDictionary* options = @{
                          ACFacebookAppIdKey: [[NSBundle mainBundle] objectForInfoDictionaryKey:@"FacebookAppID"],
                          ACFacebookPermissionsKey: @[@"public_profile", @"email", @"user_friends"],
                          };

[accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError* error)
 {
        if (granted)
        {
            ACAccount* account = [[accountStore accountsWithAccountType:accountType] lastObject];
            macFacebookAccount = account;
        }
        else
        {
            NSLog(@"%@", error); 
        }
 }];

Solution

  • I solved this: Facebook permission settings for an app are located under System Preferences > Security and Privacy. From there just click facebook and check the box next to your app