Skip to content

Commit 6a2044f

Browse files
Merge pull request #4563 from JingShing/master
Add username and password in ngrok
2 parents ec95ced + 1a01191 commit 6a2044f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

modules/ngrok.py

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

3-
43
def connect(token, port, region):
4+
account = None
55
if token == None:
66
token = 'None'
7+
else:
8+
if ':' in token:
9+
# token = authtoken:username:password
10+
account = token.split(':')[1] + ':' + token.split(':')[-1]
11+
token = token.split(':')[0]
12+
713
config = conf.PyngrokConfig(
814
auth_token=token, region=region
915
)
1016
try:
11-
public_url = ngrok.connect(port, pyngrok_config=config).public_url
17+
if account == None:
18+
public_url = ngrok.connect(port, pyngrok_config=config).public_url
19+
else:
20+
public_url = ngrok.connect(port, pyngrok_config=config, auth=account).public_url
1221
except exception.PyngrokNgrokError:
1322
print(f'Invalid ngrok authtoken, ngrok connection aborted.\n'
1423
f'Your token: {token}, get the right one on https://dashboard.ngrok.com/get-started/your-authtoken')

0 commit comments

Comments
 (0)