Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ share/python-wheels/
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# Usually, these files are written by a Python script from a template.
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Make sure to have Python 3 installed.

To run the server application, open a command terminal, and navigate to the folder where you saved this Python script.
To run the server application, open a command terminal and navigate to the folder where you saved this Python script.

Replace the required variables (Client ID, Secrect ID etc...) in the oauth.py file on lines 23 and 24, Replace the URL in the <a> tag in
Replace the required variables (Client ID, Secrect ID etc.) in the oauth.py file on lines 23 and 24, Replace the URL in the <a> tag in
index.html, then run:

*python3 oauth.py*
Expand All @@ -13,6 +13,6 @@ You should see this in the terminal:

Listening on http://0.0.0.0:10060...

copy and paste above URL into browser and follow prompts
copy and paste above URL into your browser and follow prompts

**Note**: Your Redirect_URI in the Integration's settings on Developer Webex Teams site should be: http://0.0.0.0:10060/oauth or if you're using any other hosting platform it would be https://YOUR_SERVER/oauth
**Note**: Your Redirect_URI in the Integration's settings on the Developer Webex site should be: http://0.0.0.0:10060/oauth or if you're using any other hosting platform it would be https://YOUR_SERVER/oauth
34 changes: 17 additions & 17 deletions oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@
Description : This is a utility function that takes in the
Authorization Code as a parameter. The code
is used to make a call to the access_token end
point on the webex api to obtain a access token
and a refresh token that is then stored as in the
point on the Webex API to obtain an access token
and a refresh token. These tokens are then stored in the
Session for use in other parts of the app.
NOTE: in production, auth tokens would not be stored
in a Session. This app will request a new token each time
it runs which will not be able to check against expired tokens.
it runs, which will not be able to check against expired tokens.
"""
def get_tokens(code):
print("function : get_tokens()")
print("code:", code)
#STEP 3 : use code in response from webex api to collect the code parameter
#to obtain an access token or refresh token
#STEP 3 : use the code received from the Webex API response to collect the code parameter
#in order to obtain an access token or refresh token
url = "https://webexapis.com/v1/access_token"
headers = {'accept':'application/json','content-type':'application/x-www-form-urlencoded'}
payload = ("grant_type=authorization_code&client_id={0}&client_secret={1}&"
Expand All @@ -62,12 +62,12 @@ def get_tokens(code):
"""
Function Name : get_tokens_refresh()
Description : This is a utility function that leverages the refresh token
in exchange for a fresh access_token and refresh_token
when a 401 is received when using an invalid access_token
while making an api_call().
to exchange it for a fresh access_token and refresh_token
when a 401 is received while making an api_call()
with an invaild access_token.
NOTE: in production, auth tokens would not be stored
in a Session. This app will request a new token each time
it runs which will not be able to check against expired tokens.
it runs, which will not be able to check against expired tokens.
"""
def get_tokens_refresh():
print("function : get_token_refresh()")
Expand All @@ -91,12 +91,12 @@ def get_tokens_refresh():

"""
Function Name : main_page
Description : when using the browser to access server at
Description : When using the browser to access the server at
http://127/0.0.1:10060 this function will
render the html file index.html. That file
contains the button that kicks off step 1
of the Oauth process with the click of the
grant button
render the HTML file index.html. That file
contains the button that initiates step 1
of the OAuth process with the click of the
grant button.
"""
@app.route("/")

Expand Down Expand Up @@ -134,11 +134,11 @@ def oauth():

"""
Funcion Name : spaces
Description : Now that we have our authentication code the spaces button
on the granted page can leverage this function to get list
Description : Now that we have our authentication code, the "Spaces" button
on the granted page can leverage this function to get a list
of spaces that the user behind the token is listed in. The
Authentication Token is accessed via Session Key 'oauth_token'
and used to construct the api call in authenticated mode.
and used to construct the API call in authenticated mode.
"""
@app.route("/spaces",methods=['GET'])
def spaces():
Expand Down