Webhooks failing with "Invalid Scopes: pages_messaging_subscriptions" [duplicate] - facebook

This question already has answers here:
Facebook Messenger App Invalid Scope - permission: pages_messaging_subscriptions
(3 answers)
Closed 6 years ago.
I had a submitted and approved Facebook messenger bot working. But I just got a developer update just now saying
"Your Webhooks subscription for callback URL https://BOTNAME.herokuapp.com/ has not been accepting updates for at least 16 minutes. Please verify that your callback server is functioning."
I do see that my callback server and application is working on Heroku.
This problem usually gets solved if I generate a new page access token and restart the web application with this new page access token in it. But this time I'm unable to generate an access token either.
I tried generating a new page access token from my Developer account page for the specific page on which the app is running, but the error now says
"Invalid Scopes: pages_messaging_subscriptions. This message is only shown to developers. Users of your app will ignore these permissions if present."
There is no Documentation on this. Any suggestions?

I got this message today also. This is the bug from Facebook.
Right now, you can get Page Access Token via Graph API Explorer instead of App Dashboard.
Go to: https://developers.facebook.com/tools/explorer/
Click Get Token > Get User Access Token
Select the following scopes : manage_pages, pages_messaging, and pages_messaging_phone_number.
In Application selector, select your app.
Select your page to get Page Access Token.
Now you have Page Access Token, which you can use it for your Messenger Bot.
Check whether it worked by doing :
curl -X POST "https://graph.facebook.com/v2.6/me/subscribed_apps?access_token={{your_access_token}}"

I was also having the same difficulties. Its now resolved and they have now changed the way page access token is issued.

Related

Getting "(#100) Pages Public Content Access requires either app secret proof or an app token" issue when calling Facebook API?

I am developing an app that syncs with users Facebook account and fetches Facebook page information. Initially, app asks for Login with Facebook and gets page list. After getting pages I am calling API to get posts associated with each page. Once I get post details then I am calling insight APIs to get insights of each post.
This flow working fine with development mode but when I switch to Live mode I am getting the following error
Client error: `GET https://graph.facebook.com/v4.0/100575944711552/feed` resulted in a `400 Bad Request` response:{"error":{"message":"(#100) Pages Public Content Access requires either app secret proof or an app token","type":"OAuthE (truncated...)
{"userId":1,"email":"superuser#corals.io","exception":"[object] (GuzzleHttp\\Exception\\ClientException(code: 400): Client error: `GET https://graph.facebook.com/v4.0/100575944711552/feed` resulted in a `400 Bad Request` response:
{\"error\":{\"message\":\"(#100) Pages Public Content Access requires either app secret proof or an app token\",\"type\":\"OAuthE (truncated...)
From the details what I observed I am getting this error while using,
GET /v5.0/{page-id}/feed HTTP/1.1
Host: graph.facebook.com
this endpoint. I am currently having 2 permissions approved,
manage_pages 2. read_insights
and app review team rejected 2 permissions saying the request is invalid and for this use case we don't require this which are,
1.Page Mentions 2. user_posts
Can anyone help me to understand what is the exact issue?
I had the same problem. Upon reacting to their damn changes yet again (manage_pages is not a thing anymore). I only had pages_manage_metadata but not pages_read_engagement to actually read the content on the page... -.-
I also appear this error. for me, I found that since graph api v5.0, request has changed. The docs said:
Page Public Content Access
This change applies to v5.0+
Requests made to endpoints that require the Page Public Content Access feature must be made with either an App Access Token or include the app's App Secret. If the calling app has been granted the manage_pages permission however, an app access token or app secret is not required.
If you only retrieve public data. You can use requests by app access token quick fixed. But if you want to get more. You need to follow the docs update. :)
I have fixed this issue. Everything is fine but the only issue is when authenticating with facebook login I needed to include "manage_page" permission in scope section.

Facebook API returns "Invalid OAuth access token signature."

For my website I use the Facebook API to get the events from a few Facebook pages. For this purpose I have created a Facebook app.
However, even though this used to work before, the API now returns an error:
"message": "Invalid OAuth access token signature.",
"type":"OAuthException",
"code": 190,
Here are the steps to reproduce the error:
Go to app's dashboard on https://developers.facebook.com/apps
Get the app id (APP_ID) and the app secret (APP_SECRET)
Use the app id and the app secret to get an access token by using this url:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID
&client_secret=APP_SECRET&grant_type=client_credentials
This returns something like
{"access_token":"123412342134|f34f34f32fc3rc4rc324r-X","token_type":"bearer"}
I then use this access token to access the events
https://graph.facebook.com/v2.12/{11239244970}/events/?fields={id,name}&access_token={123412342134|f34f34f32fc3rc4rc324r-X}
However, this returns the error mentioned above, "Invalid OAuth access token signature.".
I'm stuck here. None of the posts on here seem to solve my problem.
I've already tried resetting the app secret, but that didn't help. Any hints are greatly appreciated!
It would appear that the reason for this error is that Facebook currently only returns events for pages using the Pages API if you use a user access token and that user is attending, is interested in or has been invited to the events of the page (as answered by #unknown_b to a related question over here).
To get the Client Access Token for an app, do the following:
Sign into your developer account.
On the Apps page, select an app to open the dashboard for that app.
On the Dashboard, navigate to Settings > Advanced > Security > Client token.
https://developers.facebook.com/docs/facebook-login/guides/access-tokens#errors

Auto Posting to Multiple Facebook Pages using Graph API - Auth Issues

I am pulling my hair out trying to understand what Facebook wants me to do to post to a FaceBook Page as a System User that has Admin and Page Privileges to and Owned by our business (We have Facebook Business Manager).
In a nut shell all I want to do is make this call:
https://graph.facebook.com/v2.5/${MyPageID}/feed
What I don't get is the access_token part.
I can generate access tokes for Apps, for Pages but all result in 403 returned from FaceBook. I have gone as far and checking every box available on the generate access token popup on the graph api and still I get 403 "Forbidden" so I am detailing the little I understand of the insanity that is FaceBook Auth in the hope that someone can explain where I am going wrong.
1) To Post as a System User to a Page I have to Create a FB App (I Would prefer just to post direct to the pages and skip the App part, My System User has Admin Access on All pages)
2) To Access the App I need an App Token.
3) To Create an App token I need a User Token.
4) To Create a user token I need to log in to Facebook and have all sorts of permissions on the App. (I can't log in as the System User! FB asks me to login as myself. I am not sure if this breaks the Auth Token generated?)
5) Then there are all sorts of swapping tokens to get a Permanent App token, Another point of potential failure!
6) IF the stars and moon align and you stand on your head the permanent App key can be passed to the above call as the access_token
I don't understand how to link the Pages I want to post to with the App created. Do I have to have 1 App for Each Page?
I have got one page to work, We initially used that App to Auth against the Instant Article Graph API:
https://graph.facebook.com/v2.5/${MyPageID}/instant_articles
I could not use the above token for the /feed url, I had to generate a new token with extra publish permissions and the page published with no problems, however when I change the ${MyPageID} to another page using the same access_token I get the 403.
I tried Creating a new App, I have no clue how they link to a specific page So the App to me seems sort of redundant.
Any help with what I am doing wrong or how I can go about simply posting to various FB Pages with a System User using the /feed api ?
The calls are made form a Spring Boot Java APP using HTTP Posts.
How to get a System User Auth and Page Auth:
1) Generate a User Token for an App (Button above the System User):
https://business.facebook.com/settings/system-users/${System User ID}?business_id=${your_business_manager_id}
System user has Page Admin on each page you need to post to.
App is just an FB app, not sure what it does other that it is a grouping I generate a token against.
I chose: (manage_pages, publish_pages, publish_actions, pages_manage_instant_articles, pages_show_list)
2) Check your access token:
https://developers.facebook.com/tools/debug/accesstoken/?access_token=${The access token you got from the step above}&version=v2.12
This will provide you with the App ID the Token is for and how long it lasts (we need a Permanent token)
3) Using Graph API Explorer gets the Accounts this token has access to:
https://developers.facebook.com/tools/explorer/${Your FB APP ID}/?method=GET&path=me%2Faccounts&version=v2.12
4) Using the output above find Page Auth for each page you wan to publish to
5) Post to each page in turn:
https://graph.facebook.com/v2.5/${MyPageID}/feed

Facebook page access token broken after adding new permissions to user token

Based on the doc on Facebook page access token following steps are need to be taken to obtain a long-lived Page Access Token.
Extend the User's Access Token which has the manage_pages permissions
Get the page access token thru the /userId/accounts end point using the extended user access token.
This process is working fine and I am able to obtain and use the page access token properly.
The issue arises when the user grants a new permission to the App - such as 'publish_actions' to allow the App to post on the Page's timeline, the page access token obtained using the above mentioned mechanism does not work properly.
Until about a 6 to 8 weeks ago the new publish_action permission would allow the previously saved page access token to post on the page's timeline without any issue. This feature seems to have broken where I am getting the following error :
{"error":{"message":"(#200) The user hasn't authorized the application to perform this action","type":"OAuthException","code":200
When the access token is debuged using the Facebook debugger tool - it shows that the saved page access token is indeed embellished with the new permission as follows :
App ID XXXXXXXXXXXX : App Name
Profile ID 999999999999 : Page Name
User ID 9999999999999999 : User Name
User last installed this app via API v2.x
Issued 1454463877 (40 minutes ago)
Expires Never
Valid True
Origin Web
Scopes email, manage_pages, publish_actions, public_profile
So although this page token has publish_actions permission it is not able to post on the page's timeline. This has stopped working recently and looking for any other folks who have faced a similar issue and have managed to resolve it.
Btw, I have already tried refreshing the page access token using the newly generated user access_token at the time when the user gives the publish_actions permission. Going the thru the above 2 steps using the new user access token, seem to return the same page access token and it continues to fail to post on timeline...
Any help is much appreciated.
The issue was related to using incorrect permission. Facebook has introduced a new 'Publish_pages' permission which should be used to make posts on business pages. We were using publish_action which was invalid (since v2.3 or somewhere around that - we are using v2.5 of the graph API so it caused a problem).
Facebook responded pretty quickly to our bug report and provided this guidance which helped resolve this issue (I should have posted this answer earlier).

Unable to post to facebook page using app token

I am building my first facebook app and am facing a issue.
Task : Build a entirely server side application to be used by the admin of a facebook page to post videos/photos on the page. This should not involve having the admin to log in everytime to generate the user acess and page access token.
What I found : Based on the requirement, I found that app tokens can be used for this purpose. This line specifically hints at the usefulness.
App access tokens can also be used to publish content to Facebook on behalf of a person who has granted an open graph publishing permission to your application
I think that using this will be safe since mine is an entirely server side app.
Problem The docs say that:
GET /oauth/access_token?
client_id={app-id}
&client_secret={app-secret}
&grant_type=client_credentials
will give the app token that can be used in place of user access token.
However, I have not been able to do so. Specifically the error encountered is
Error 200 .The user must have accepted the TOS. Since I have already tried publishing content with page access token, I know this is a permission issue.
The following line
a person who has granted an open graph publishing permission to your application.
does not clarify everything. I came across a related question, but the answers seem to be a bit vague.
It would be really great if someone could give me insights about how this can be achieved.
In order to post to a page, you need at least authorize with the manage_pages permission. If you want to post "as user", you need to add publish_actions and use a "User Access Token". If you want to post "as page", you need to add publish_pages and use a "Page Access Token".
Information about how to generate those Tokens:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
The error message with the TOS has been discussed a lot of times already, please go to those threads (or find a lot more with the search function):
(OAuthException) (#200) User must have accepted TOS on C# - Facebook
How come I get a "must have accepted TOS" error for test users with app installed?
facebook long term token "(#200) User must have accepted TOS"
Occassional (OAuthException - #200) (#200) User must have accepted TOS
You cannot post to a Page via an App Access Token. This is clearly stated in the docs at
https://developers.facebook.com/docs/graph-api/reference/v2.3/page/feed#publish
A user access token with publish_actions permission can be used to publish new posts on behalf of that person. Posts will appear in the voice of the user.
A page access token with publish_pages permission can be used to publish new posts on behalf of that page. Posts will appear in the voice of the page.
I'd recommend to use a eternal Page Acess Token, so there's no obligation to renew the User Access Token. Have a look at my answer here:
Post to a facebook page without "manage_pages" permission using php
See
https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens