Skip to content

Commit 8e98af9

Browse files
committed
comment ngrok to make it an option
1 parent ce828b4 commit 8e98af9

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

examples/oauth-flask-ngrok.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from webexteamssdk import WebexTeamsAPI
4545

4646
# Parameters configured in Webex Integration
47-
OAUTH_CLIENT_ID = "your integration client ID"
47+
OAUTH_CLIENT_ID = "your integration Client ID"
4848
OAUTH_CLIENT_SECRET = "your integration Client Secret"
4949
OAUTH_CALLBACK_URI = "http://localhost:5000/callback"
5050
# Scopes are space-separated. Can use any subset of the configured scopes.
@@ -54,11 +54,16 @@
5454
oauth_authorizationUri = "https://webexapis.com/v1/authorize?"
5555
oauth_tokenUri = "https://webexapis.com/v1/access_token"
5656

57-
58-
# Get the ngrok public URI. It can be used instead of the localhost URI, as long
59-
# as it is also configured in the Webex integration
60-
r = requests.get("http://localhost:4040/api/tunnels")
61-
public_url = r.json()['tunnels'][0]['public_url']
57+
# On a local machine, this script will run even without a public callback URI.
58+
# But in reality the user is never on the same computer with the server. To
59+
# enablre remote user access, an Ngrok public URI has be used instead of the
60+
# local URI.
61+
# Uncomment the lines below to automatically get the public URI from
62+
# ngrok and use it instead of the local one. This public URI must also be
63+
# configured in the Webex Integration as a Redirect URI.
64+
#
65+
# r = requests.get("http://localhost:4040/api/tunnels")
66+
# public_url = r.json()['tunnels'][0]['public_url']
6267
# OAUTH_CALLBACK_URI = public_url + "/callback"
6368

6469
# Create Flask app instance
@@ -68,19 +73,19 @@
6873
app.secret_key = "very bad secret"
6974

7075

71-
# Welcome page. Link to auth from this page.
76+
# Welcome page. Link to auth from this page, or from anywhere else.
7277
@app.route("/")
7378
def root():
7479
print("/ requested")
7580
return ("""
7681
<p>Hey, this is Flask!</p>
77-
<p>Click <a href="{}">here</a> to authenticate Webex integration.</p>
82+
<p>Click <a href="{}">here</a> to authorize Webex Integration.</p>
7883
""".format(url_for("auth")))
7984

8085

8186
# OAuth Step 1 - Build authorization URL and redirect user.
82-
# Redirect the user/resource owner to the OAuth provider using an URL with a few
83-
# key OAuth parameters.
87+
# Redirect the user/resource owner to the OAuth provider (Webex) using an URI
88+
# with a few key OAuth parameters.
8489
@app.route("/auth")
8590
def auth():
8691
print("Authorization requested")
@@ -109,9 +114,9 @@ def auth():
109114

110115
# OAuth Step 3 - Receive authoriation code and obtain access token.
111116
# The user has been redirected back from the provider to your registered
112-
# callback URL. With this redirection comes an authorization code included
113-
# in the redirect URL. We will use that code to obtain an access token.
114-
# The access token can be then used for any API calls within the authorized scopes.
117+
# callback URI. With this request comes an authorization code included in the
118+
# redirect URI. We will use that code to obtain an access token. The access
119+
# token can be then used for any API calls within the authorized scopes.
115120
@app.route("/callback", methods=["GET"])
116121
def callback():
117122
print("OAuth callback received")
@@ -136,7 +141,7 @@ def callback():
136141

137142
# 1.
138143
# The API connection can be directly initialized with OAuth information. It
139-
# will exchange the OAuth authorization code to access token behind the
144+
# will exchange the OAuth authorization code to an access token behind the
140145
# scenes. It is the easiest, but the drawback is the refresh token is lost
141146
# and cannot be saved.
142147
api = WebexTeamsAPI(

0 commit comments

Comments
 (0)