Thursday 18 March 2021

How to authenticate ngrok password automatically using Python and or Javascript?

I am using ngrok to expose my localhost on a raspberry pi, and ngrok is password protected. I am using Django on another computer outside my network to access a webpage(simple server) on this raspberry pi. I don't want to manually type in the username and password to ngrok.

How can I automatically fill in the ngrok user/password, which is a popup in chrome asking for user and password?

What I've tried: I first tried using JS in my template, just using a fetch request: https://user:password@myngrokdomain.ngrok.io but chrome threw an error in the console saying I can't pass in credentials in plain text like this, rightfully so...

I then tried to use python requests:

    UN= "myuser"
    PWD = "mypassword"
    loginURL = "https://myngrokdomain.ngrok.io"
    client = requests.session()
    login_data = dict(username=UN, password=PWD,)
    r = client.post(loginURL, data=login_data)

This returned a 401 access denied

r.headers + r.reason returns: 401 Unauthorized Unauthorized {'Content-Length': '16', 'Content-Type': 'text/plain', 'Www-Authenticate': 'Basic realm="ngrok"', 'Date': 'Tue, 16 Mar 2021 15:22:15 GMT'}



from How to authenticate ngrok password automatically using Python and or Javascript?

No comments:

Post a Comment