facebook-graph-apifacebook-messages

Messenger Platofrm subscribing app error: permission pages_messaging is required to register webhook


From our app we want users to be able to authenticate with Facebook and to be able chat from within our app with their Facebook Page visitors (webhook / Send API).

We are able to get the page access token, but are having trouble subscribing our Facebook app to the page using the page access token.

The steps are as follows:

  1. User initiates authentication

    https://www.facebook.com/dialog/oauth?client_id=[client_id]&redirect_uri=[redirect_uri]&state=[state]&scope=publish_pages,manage_pages,pages_messaging

  2. Exchange code for user access token

    /v2.7/oauth/access_token?client_id=[client_id]&redirect_uri=[redirect_uri]&client_secret=[client_secret]&code=[code]

  3. Get Pages (and page access tokens) using user token

    /v2.7/me/accounts?access_token=[user_access_token]

  4. Subscribe our app to the Facebook Page using obtained page access token

    /v2.7/me/subscribed_apps?access_token=[page_access_token]

This is where we are having trouble. The response from step 4 is:

(#230) permission pages_messaging is required to register webhook for messages or deliveries

All API calls are using v2.7 and the manage_pages, publish_pages and pages_messaging permissions have all been approved for the app.

Any ideas or help on what we are missing?


Solution

  • pages_messaging is only available since API v2.7

    You are making an unversioned call to the login dialog, so it will fall back to the lowest API version your app can use. If that’s not 2.7, your attempt at asking for pages_messaging will be ignored.

    Specify the API version in your login dialog call:

    https://www.facebook.com/v2.7/dialog/oauth?…
                             ^^^^