0

I am trying to subscribe my facebook chatbot to the user's page, using the manage_pages permission.

I already have the permission approved to my app, but I am having trouble, because the token is generated in the browser(in Brazil), but I send it to aws lambda in US west 2, and I get the following error

The \'manage_pages\' permission must be granted before impersonating a user\'s page.

In my test, I run the subscribe process in my machine, and reuse this token in AWS Lambda(US West 2). After researching and making some tests, I figured out that it just dont work in USA, in Brazil it works. Using the same token generated in the process, I run the following test.

var request = require("request")
request.post("https://graph.facebook.com/v2.9/me/messages", {
    qs: {
        access_token: "GENERATED TOKEN"
    },
    json: {
        "recipient": {
            "id": "USER_ID"
        },
        "message": {
            "text": "hello!"    
        }
    }
},function(e){
    if(e){
        return console.log("ERROR",e)
    }
    console.log("FINISH",arguments)
})

When I run with my internet, it works fine, but If I use a VPN in Miami, the error occurs.

I believe it has something to do with the data replication that facebook does, but how can I make this token be accessible by the USA region?

EDIT

I found this error when starting the facebook login process with the VPN online:

facebookerror

I didnt find any restrictions in my app, where can I check this?

Charles Stein
  • 126
  • 1
  • 7
  • Are you trying this immediately after you created the token? Do things change if you let more time pass between creating the token in Brazil, and making the API request from the US? – CBroe Apr 21 '17 at 07:38
  • No difference, I tryed again the same token and the same error occurs, I found something that maybe is the cause, see in the edit section – Charles Stein Apr 21 '17 at 13:00
  • In app dashboard, check under Settings -> Advanced, App Restrictions – CBroe Apr 21 '17 at 13:31
  • Solved, thanks a lot, could you post in the answer section? – Charles Stein Apr 21 '17 at 14:00
  • Since you kinda found the cause yourself ... why not write a self-answer. (Feels like my contribution here was rather to small to warrant an answer by me ;-) – CBroe Apr 21 '17 at 14:31

1 Answers1

0

The problem was occurring because my app had coutry restriction to only Brazil, I added United States to restrictions and it worked. The restriction can be changed in Settings -> Advanced, App Restrictions

Charles Stein
  • 126
  • 1
  • 7