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

Question:

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?

Asked By: Brady Huang

||

Answers:

It is done via the Auth tab of your ngrok dashboard. From IP Whitelisting Tunnel Access:

You may whitelist access to tunnel endpoints on your account. The
whitelist is enforced by the ngrok.com servers. It is applied globally
to all of your tunnel endpoints. Any incoming connection to any of
your tunnel endpoints is checked to guarantee that the source IP
address of the connection matches at least one entry in your
whitelist. If a connection does not match the whitelist it is
terminated immediately and never forwarded to an ngrok client.

As a special case, if your whitelist is empty, all connections are
allowed
.

Managing the whitelist

You can manage the IP whitelist on the auth tab of your ngrok
dashboard. Enter a new IP address under the “IP Whitelist” section and
then click Add Whitelist Entry. Changes to the IP Whitelist can
take up to 30 seconds to take effect.

IP Ranges

Sometimes, you may wish to whitelist an entire range of IPs. Instead
of entering just a single IP address, you may instead specify a block
of IP addresses using CIDR notation. For example, to allow all IP
addresses from 10.1.2.0 to 10.1.2.255, you would add 10.1.2.0/24 to
your whitelist.

Answered By: Dan Cornilescu

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).

Answered By: Arnaud Valle

I had a slightly different question, but google lead me here none the less, the error I had was:

"The callback URL or verify token couldn’t be validated. Please verify the provided information or try again later."

When trying to connect facebooks webhook to my localhost. Turns out I needed to authenticate my ngrok agent:
https://dashboard.ngrok.com/get-started/your-authtoken

Answered By: Gherkin in God mode

switch your ngrok server location and it works ngrok http 3000 --region ap work for me also.

ngrok http -region us 80 (US is not working)
ngrok http -region eu 80
ngrok http -region ap 80
ngrok http -region au 80

Answered By: Nidhish