Forums

ngrok 403 forbidden

I want get access to URL like this: 'http://login:password@code.ngrok.io' throw my telegram Bot.

I have code like this

import requests
import telebot


login = 'login'
password = 'pass'
code = '12312312'

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36'}

main_URL = 'http://' + login + ':' + password + '@' + code + '.ngrok.io'
req_URL = 'http://' + login + ':' + password + '@' + code + '.ngrok.io/command.html'


@bot.message_handler(commands=['down'])
def down(message):
    r = requests.get(main_URL, headers=headers)
    bot.send_message(message.chat.id, r.status_code)

After that I get, error 403 forbidden. But .ngrok.io is in your whitelist.

Even main_URL = 'http://ngrok.io' does not work.

requsts.post(req_URL, data=payload) # doesn't work too

But from http://google.com or other sites in your whitelist i get good answer - 200

r.status_code = 200

Based on your post, that Forbidden is being returned by ngrok, not by PythonAnywhere, so you should work out why the ngrok is returning a 403. Looking at the content of the response can often be useful.

https://3ea6-49-36-213-66.ngrok-free.app i am trying to access this url that is generated by ngrok for free users earlier the url for free users ended with .ngrok or .ngrok.io that are whitelisted by pythonanywhere but this new format .ngrok-free.app is not whitelisted can you please also whitelist this format??

Check out this help page for details on how to get a site added to the allowlist.