Reputation: 4783
I have a Slack app that I'm trying to auth using Python and flask.
I'm simply following this page to try and get this working, but for whatever reason it's not at all. https://ngrok.com/docs/getting-started/#step-1-install
I downloaded an ngrok agent, authenticated it with this:
ngrok config add-authtoken $YOUR_AUTHTOKEN
then ran this command:
ngrok http http://localhost:8080
But I keep getting a reconnecting error.
When I run a ngrok diagnose
I get the following error saying "no tunnel servers were reachable via TCP". I'm too sure how to solve that.
Testing ngrok connectivity...
Internet Connectivity
Name Resolution [ OK ]
TCP [ OK ]
TLS [ OK ]
Localhost Connectivity
Name Resolution [ OK ]
Ngrok Connectivity - Region: Auto (lowest latency)
Name Resolution [ OK ]
TCP [ ERROR ]
Errors and warnings encountered during diagnostics:
* Diagnostics
* Connectivity
- Err: No tunnel servers were reachable via TCP.
(ERR_NGROK_8007)
* connect.ngrok-agent.com (52.220.69.60:443)
- Err: Failed to establish TCP connection to 52.220.69.60 with error:
dial tcp 52.220.69.60:443: connectex: A connection attempt failed
because the connected party did not properly respond after a period
of time, or established connection failed because connected host
has failed to respond.
(ERR_NGROK_8002)
* connect.ngrok-agent.com (13.251.162.108:443)
- Err: Failed to establish TCP connection to 13.251.162.108 with error:
dial tcp 13.251.162.108:443: connectex: A connection attempt failed
because the connected party did not properly respond after a period
of time, or established connection failed because connected host
has failed to respond.
(ERR_NGROK_8002)
* connect.ngrok-agent.com (52.220.126.110:443)
- Err: Failed to establish TCP connection to 52.220.126.110 with error:
dial tcp 52.220.126.110:443: i/o timeout
(ERR_NGROK_8002)
* connect.ngrok-agent.com (18.141.102.200:443)
- Err: Failed to establish TCP connection to 18.141.102.200 with error:
dial tcp 18.141.102.200:443: i/o timeout
(ERR_NGROK_8002)
Error establishing ngrok connection:
No tunnel servers were reachable via TCP.
(ERR_NGROK_8007)
Report written to C:\Users\jlabbe\AppData\Local\Temp\ngrok-diagnose1993098929/diagnose.json
ERROR: Error establishing ngrok connection:
ERROR: No tunnel servers were reachable via TCP.
ERROR: (ERR_NGROK_8007)
ERROR: https://ngrok.com/docs/errors/(err_ngrok_8007)
ERROR:
Here's my Python script to show how I'm connecting my app with Flask.
import html
from slack_sdk.oauth import AuthorizeUrlGenerator
from slack_sdk.oauth.installation_store import FileInstallationStore
from slack_sdk.oauth.state_store import FileOAuthStateStore
from flask import Flask, redirect, request
SLACK_CLIENT_ID = "<MY_CLIENT_ID>"
state_store = FileOAuthStateStore(expiration_seconds=300, base_dir="./data")
installation_store = FileInstallationStore(base_dir="./data")
app = Flask(__name__)
# Build https://slack.com/oauth/v2/authorize with sufficient query parameters
authorize_url_generator = AuthorizeUrlGenerator(
client_id=SLACK_CLIENT_ID,
scopes=["app_mentions:read", "chat:write"],
user_scopes=["bookmarks:read", "bookmarks:write", "canvases:read", "canvases:write", "chat:write", "groups:history",
"groups:read", "groups:write", "groups:write.invites", "groups:write.topic", "pins:read", "pins:write"],
)
@app.route("/slack/install", methods=["GET"])
def oauth_start():
state = state_store.issue()
url = authorize_url_generator.generate(state)
return f'<a href="{html.escape(url)}">' \
f'<img alt=""Add to Slack"" height="40" width="139" src="https://platform.slack-edge.com/img/add_to_slack.png" srcset="https://platform.slack-edge.com/img/add_to_slack.png 1x, https://platform.slack-edge.com/img/[email protected] 2x" /></a>'
if __name__ == "__main__":
print("install at 'http://localhost:8080/slack/install'") # Url opens ok
app.run(host='0.0.0.0', port=8080)
Does anyone have any idea why it's failing?
Upvotes: -2
Views: 57