pythonpycharmwebhooksfacebook-chatbotfacebook-webhooks

Use ngrok url as callback url for facebook webhook, but is recognized "not whitelisted"


My IDE is Pycharm. I want to test my app locally, so I run my service locally and use ngrok to expose my app to Internet.

The url showed by ngrok is https://436cb7e9.ngrok.io

But when I want to verify the facebook webhook callback url use this url above, it shows

ERROR 2017-12-27 08:16:37,407 wsgi_server.py:329] Request Host 436cb7e9.ngrok.io not whitelisted. Enabled hosts are set(['localhost'])

I ran the app well before, but I don't know why this time it shows an error. Could somebody gives me suggestion?


Solution

  • After a bit of digging and thanks to Brady's comment about the gcloud version, I found out that all you need to fix this is to add a flag when you run your app.

    So, say you run your app locally with:

    python $APPENGINE/dev_appserver.py
    

    just change it to:

    python $APPENGINE/dev_appserver.py --enable_host_checking=false
    

    and you should not have the host whitelist errors anymore.

    For more information, checkout the release notes here: https://cloud.google.com/appengine/docs/standard/python/release-notes#december_5_2017

    This seems to be working fine for me on gcloud 183.0.0 and 187.0.0 (the latest version at the time of writing of this comment).