Search code examples
node.jsfacebook-messengerwhitelistfacebook-messenger-botbotkit

Domains are not being added, Whitelist domains facebook messenger extension


I've been trying to whitelist my domains following the instruction that is given by facebook but nothing is working.

I first tried with curl, the response is {result:"success"} but when I try to list the domains that are whitelisted I am getting {data:[]}

Then I tried using node request module as follow:

request.post("https://graph.facebook.com/v2.6/me/messenger_profile?access_token=sfdlksdfu79r9429049824982342348sjdfsf", {
                "setting_type": "domain_whitelisting",
                "whitelisted_domains": ["https://mydomainw.com", "https://mydomainw.com/profile", "https://sfujyx.com/ofr", "mydomain1.com", "mydomain.com"],
                "domain_action_type": "add"}, function (err, res, body) {
                console.log("Whitelisting domain");
                if (!err) {
                    console.log(body);
                    console.log("Showing the list of whitelisted:");
                    request.get("https://graph.facebook.com/v2.6/me/messenger_profile?fields=whitelisted_domains&access_token=sfdlksdfu79r9429049824982342348sjdfsf", function (err, res, body) {
                        if (!err) {
                            console.log(body);
                        } else {
                            console.log(err);
                        }
                    });
                } else {
                    console.log(err);
                }
            });

Still it bring the same result as curl :

Screen shot of the result of the code

And when I use Facebook Graph Api Explorer tool, here is the error I am getting:

Graph Api tool, to whitelist domain

I am really stuck, I don't know what should I do or how people exactly whitelist domain for messenger extension.

What I am doing wrong? why isn't the domains being added?

My project is on Google App Engine.


Solution

  • The problem is I was using the App Access Token instead of the Page Access Token, I didn't know the difference.