Skip to content

Commit 2505f39

Browse files
authored
Add username and password in ngrok.
1 parent ac08562 commit 2505f39

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

modules/ngrok.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
from pyngrok import ngrok, conf, exception
22

3-
43
def connect(token, port, region):
54
if token == None:
65
token = 'None'
6+
else:
7+
if ':' in token:
8+
# token = authtoken:username:password
9+
account = token.split(':')[1] + ':' + token.split(':')[-1]
10+
token = token.split(':')[0]
11+
712
config = conf.PyngrokConfig(
813
auth_token=token, region=region
914
)
1015
try:
11-
public_url = ngrok.connect(port, pyngrok_config=config).public_url
16+
if account:
17+
public_url = ngrok.connect(port, pyngrok_config=config, auth=account).public_url
18+
else:
19+
public_url = ngrok.connect(port, pyngrok_config=config).public_url
1220
except exception.PyngrokNgrokError:
1321
print(f'Invalid ngrok authtoken, ngrok connection aborted.\n'
1422
f'Your token: {token}, get the right one on https://dashboard.ngrok.com/get-started/your-authtoken')

0 commit comments

Comments
 (0)