Skip to content

Example code of Python with Flask to do Webex Teams authentication using oAuth

License

Notifications You must be signed in to change notification settings

DJF3/Webex-Teams-Flask-oAuth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 

Repository files navigation

published

Webex Message Flask oAuth Integration

Example code of Python with Flask to do Webex Message (Teams) authentication using oAuth. This example uses Flask, a tiny webserver in Python.

Start

  1. Prepare
  2. Create Webex Integration (oAuth)
  3. Update script
  4. Run script
  5. Result

Then:

  1. Download & Install Python 3.6 or higher
  2. Install Flask: system wide or in a virtual environment (if you don't know what that is, ignore it)
  3. Test your setup: type "Python -V" and check the version number.
    • version >3.6 or higher: continue
    • version <3.6: try again with "Python3 -V"
  4. In Python type "import flask" and press enter. If there's no error message, continue, otherwise troubleshoot.

In case you're wondering: how does oauth work?

  1. https://developer.webex.com
  2. Login
  3. "My Webex Apps" (click your Avatar on the top right)
  4. Create a New App
  5. Integration
  6. Integration name: pick a useful and descriptive name
  7. Contact email: your account email
  8. Icon: select one
  9. Description: tell yourself what you are testing
  10. Redirect URI: the URL that Webex needs to go to when you authenticated succesfully (http://127.0.0.1:5000/gologin) (thanks muthvar1!)
  11. Scopes: spark:people_read
  12. Add integration
  1. With the new integration in place, copy the Client_Id and Client_Secret (be careful that you don't confuse these with the 'Integration ID' that's also displayed!)
  2. Open the Python script and paste the Client_Id and Client_Secret in the variables.
  1. In a terminal window (or command prompt), go to the folder that contains your script
  2. Run the script "Python python-oauth.py" (or "Python3" if you also have Python v2)
  3. You should see Flask starting and waiting to work
  4. Open a browser and go to http://127.0.0.1:5000
  5. Click "here" to login and see what happens.
  • First page

                

  • Click 'here', redirect to Webex Message, Authenticate, then click "Accept" to allow your code to 'do stuff on your behalf' (using the oAuth access token to retrieve your name and email address)

                

  • The result

                

  • Mac users: use the Atom editor and make sure it has Python syntax highlighting (BTW, one of my favourite packages is "highlight-selected")
  • Windows users: Notepad++

Take a look at the code! I've tried to keep it as simple as possible. When reading it you should be able to understand what's happening and which steps are taken. Also look at the oAuth flow image below Look at these other resources:

I've taken one of the summary slides from my oAuth presentations.

                         

More projects...

...more information posted here:

Enjoy! DJ

About

Example code of Python with Flask to do Webex Teams authentication using oAuth

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages