skip to Main Content

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.

3

Answers


  1. Chosen as BEST ANSWER

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


  2. your domain: “https://mydomainw..com” is an invalid domain.

    The request should return:

    {
      "error": {
        "message": "(#100) whitelisted_domains[0] should represent a valid URL",
        "type": "OAuthException",
        "code": 100,
        "fbtrace_id": "Aq3AVaNVJU9"
      }
    }
    
    Login or Signup to reply.
  3. Actually, I didn’t use “setting_type” before. This is how I register domains:

    var request = require("request");
    
    var options = { method: 'POST',
      url: 'https://graph.facebook.com/v2.6/me/messenger_profile',
      qs: { access_token: 'my_page_token' },
      headers: { 'content-type': 'application/json' },
      body: 
       { whitelisted_domains: 
          [ 
            'https://mydomainw.com',
            'https://ijuugwivbc.localtunnel.me' ] },
      json: true };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
    
      console.log(body);
    });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search