Facebook OAuthException: "user did not allow the application to perform this action"

Using the PHP SDK for Facebook, I get the following error when trying to post a status update:

Fatal error: OAuthException could not be thrown: (# 200) The user did not allow the application to complete this action

These are the steps I took:

  • To get the code:

    https://graph.facebook.com/oauth/authorize?client_id=FB_APP_ID&redirect_uri=REDIRECT_URI 
  • Get access token:

     https://graph.facebook.com/oauth/access_token?client_id=FB_APP_ID&code=CODE&client_secret= FB_SECRET&redirect_uri=REDIRECT_URI 
  • Try updating status:

     require_once(facebook.php); $fb = new Facebook(array( 'appId' => FB_APP_ID, 'secret' => FB_SECRET )); $post = $fb->api('me/feed', 'POST', array( 'access_token' => ACCESS_TOKEN, 'message' => 'hello world!' )); 

I do not see any parameters in my application that would allow the application to do this, but maybe I missed something. Any suggestions?

+7
php facebook oauth
source share
4 answers

Make sure you request extended publish_stream permission when requesting code (added as the third parameter):

 https://graph.facebook.com/oauth/authorize?client_id=' . FB_APP_ID . '&redirect_uri=' . REDIRECT_URI . '&scope=publish_stream' 

Hope this helps.

Hooray!

+12
source share

I had the same problem and this post really helped me http://facebook.stackoverflow.com/a/8502709/965536

The only difference of my problem was that I used the PHP SDK, but essentially it works the same. I used api call

 $permissions = $facebook->api('/me/permissions'); 

Then you can do your checks

 if(isset($permissions['data'][0]['publish_stream']) && $permissions['data'][0]['publish_stream']) 

This works for me, but someone may have a better answer. You should also wrap your publish publish stream in try catch

Hope this helps.

thanks

+6
source share

I have added additional information here:

Mark answered above, led me in the right direction. But it took me another 5 hours to understand the solution.

So here is the result for omniauth.rb:

 provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET'], :scope => 'email,user_birthday,publish_actions' 
+1
source share

Have other steps been taken to connect the user to your application and force them to allow your application to perform these actions? You need to register users and then call showPermissionDialog so that they log in and authorize your application. That this error tells you.

0
source share

All Articles