Why does requestAccessToAccountsWithType facebook fail with "Invalid Permission: photo_upload"

652 views Asked by At

I am trying to get access to Facebook to post images to a page from an iOS app. But so far I can't even get it to give me the permissions I need.

I've done a lot of searching including iOS 6 Facebook posting procedure ends up with "remote_app_id does not match stored id" error and Facebook Graph Api Fan page photo upload (IOS) but nothing in those or other posts is solving this issue.

Here is the auth bit of the code:

ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];

NSDictionary *options = @{
                          ACFacebookAppIdKey: @"xxxxxxxxxxxxxx",
                         ACFacebookPermissionsKey: @[@"manage_pages"],
                          ACFacebookAudienceKey: ACFacebookAudienceEveryone
                          };

[accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error)
 {
     if (granted)
     {
         NSDictionary *options = @{
                                   ACFacebookAppIdKey: @"xxxxxxxxxxxxxx",
                                   ACFacebookPermissionsKey: @[@"photo_upload"],
                                   ACFacebookAudienceKey: ACFacebookAudienceEveryone
                                   };

         [accountStore requestAccessToAccountsWithType:accountType options:options completion:^(BOOL granted, NSError *error)
          {
              if (granted)
              {
                   // then do the upload - but it never gets here
              }
              else
              {
                   // handle error - this is where it ends up
              }
          }];
     }
     else
     {
          // handle error
     }
 }];

As suggested on some of the other posts on this I am requesting the read permissions first before the write ones. It gets the manage_pages permission fine.

When I ask for the photo_upload permission the Facebook permissions alert pops up asking me to confirm that it can post on my behalf and I click OK - but that permission request block returns with granted set to FALSE.

The full error message I am getting at that point is "The Facebook server could not fulfill this access request: Invalid permission: photo_upload"

On the Facebook App site I think I have done everything I need to do: I have created my App and got an AppId, added iOS as a platform and set the BundleId to the same one the iOS app is using, and on the advanced tab set it to be a Native app.

Has anyone got any ideas what I am doing wrong?

1

There are 1 answers

5
urnotsam On BEST ANSWER

Use publish_actions as your permission. The new Facebook API suggests using publish_actions in place of publish_stream when applicable. publish_stream should be included when you want to add the following capabilities posting to a friend’s feed, posting questions, creating notes, and posting content to events or groups.