image

published Run in Cisco Cloud IDE

OAUTH 2.0

What is OAuth? Meet this protocol you use so often. - Applications and Systems

The OAuth 2.0 Authorization for Webex Integrations

OAUTH 2.0

2023

Authorization framework standard that allows a user to grant a third-party web site or application access to the user's protected and control access to their applications and resources. In the OAuth2 flow, there are typically four parties involved: the user, the client (the application requesting access to the user's resources), the authorization server (responsible for authenticating the user and obtaining their consent), and the resource server (where the user's protected resources are stored).

The OAuth2 protocol works by using access tokens, which are issued by the authorization server after the user grants permission to the client. These access tokens are then presented to the resource server by the client to gain access to the protected resources on behalf of the user. This separation of authorization and resource servers allows for increased security, as the client never directly handles the user's credentials.

Requirements

  1. Create an account in the portal web Webex for Developers
    https://developer.webex.com/.

  2. Create your Webex Apps

  1. Create a virtual environment in python 3.9 +
  • Store the variables as environment variable in your system Linux for clientID and secretID.

clientID = "Cb4268541f68984c205305cd19f1ecec03ca8d26f57230704771"

secretID = "2826a140ad33730e2ab787a44ca4c714d6cc4cb5896168"

  • Take note about your redirect URI that is web page that cisco going to redirect after success authentication.
    The redirectURI variable, remplace the value in your code.

redirectURI = "http://127.0.0.1:2000/redirect.html"

  • OAuth Authorization URL is used in the code index.py in the "oauthUrl" variable, remplace the value in your code.

oauthUrl = "https://webexapis.com/v1/authorize?client_id=Cb4268541f68984c205305cd19f1ec4769fde9e26f57230704771&response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1%3A2000%2Fredirect.html&scope=spark%3Aall%20spark%3Akms&state=set_state_here"

Process in Linux:

 devnet@PC1$ export secretID="2826a140ffe0643ee2ab787a44ca4c714d6cc4cb5896168" > ~/.bashrc
 devnet@PC1$ export clientID="Cb4268541f6898e9e3142ec03ca8d26f57230704771" > ~/.bashrc
 devnet@PC1$ source ~/.bashrc
 (oauth) devnet@PC1$ echo $secretID
 2826a140ffe0643eb3a5ad2244ad33730e2ab787a44ca4c714d6cc4cb5896168
 (oauth) devnet@PC1$ echo $clientID
 Cb4268541f68984c205305cd19f1ec4769fde9e3142ec03ca8d26f57230704771
  1. Activate Flask in your virtual environment and install the libraries
    listed in requirements.txt
devnet@PC1$ python3.10 -m venv oauth

devnet@PC1$ source oauth/bin/activate

devnet@PC1$ pip install -r requirements.txt

Flow OAuth 2.0

Build - Login with Webex | Webex for Developers

Proof of Concept

oauth.mp4

References

View code on GitHub

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.