broc.seib
broc.seib

Reputation: 22771

why does posting to facebook page yield "user hasn't authorized the application"

I have read the fb docs and written code to publish a message to a facebook "page", however I am getting an error that I don't expect to see:

(#200) The user hasn't authorized the application to perform this action

Here's what I've done:

This block of data for my page looks like:

{
  "data": [
    {
      "category": "Community", 
      "name": "My Generic Test Page", 
      "access_token": PAGE_ACCESS_TOKEN, 
      "id": PAGE_ID, 
      "perms": [
        "ADMINISTER", 
        "EDIT_PROFILE", 
        "CREATE_CONTENT", 
        "MODERATE_CONTENT", 
        "CREATE_ADS", 
        "BASIC_ADMIN"
      ]
    }, 
    ....
  ]
}

Then I use the PAGE_ACCESS_TOKEN to post a message to the page:

Facebook returns:

{
  "error": {
    "message": "(#200) The user hasn't authorized the application to perform this action", 
    "type": "OAuthException", 
    "code": 200
  }
}

Using the token debugger, I can confirm that my PAGE_ACCESS_TOKEN is valid, and has scopes: manage_pages and publish_actions.

Where am I missing authorizing the application? Do I need additional scopes? Did I miss clicking something on the facebook authorization screen? Is there a setting on the app I am missing? After days of debugging this, I must be blind to the problem. :-|

Upvotes: 15

Views: 48023

Answers (4)

The Coder
The Coder

Reputation: 5355

I found the best way to get a valid token and check permissions was via the Graph API Explorer BUT while Facebook's documentation is extensive it is not always the easiest to follow.

In the explorer you have to look at both:

  1. The Application Currently at the top and quite subtle, I missed this for ages.
  2. Get Token Dropdown What you click to get a Token, when you click the arrow you can choose pages and other items you have access to for selecting a token for.

Upvotes: 1

syldor
syldor

Reputation: 1176

status_update is not used anymore. To publish on pages, I had to use both manage_pages and publish_pages.

Upvotes: 3

DD_
DD_

Reputation: 7398

Well, this seems to be a common mistake that most of us make while trying to do an activity in social netwroks. Before trying to put up an open graph action,You need to set the permissions in your initial authorization request . By default you only gain 'read-only' access to their basic information. Settintg up permisson at teh time of authetication is a must for Facebook and LinkedIn APIs..

See the public_actions section in Facebook open graph permissions here and make relevant changes in the authorization code , and get your issue solved.

Upvotes: 2

Related Questions