cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
717
Views
10
Helpful
1
Replies

Python webexteamssdk oauth token expires

bunjiega
Level 1
Level 1

I am trying to build a script that will send a message to a WebEx room when an event happens.

I registered a OAUTH integration app, but the key expires when I use it after a bit (which is expected).

 

Currently, I have to manually paste the OAuth authorization URL into the browser and click 'accept' in order to get the 'code' URL parameter that the script needs. Is there a way I can automate this? I can't manually perform this step every few hours.

 

I am trying to use the webexteamssdk, but all the documentation talks about using the personal access token which is not supposed to be used in production.

 

Example of Code

from webexteamssdk import WebexTeamsAPI

api = WebexTeamsAPI(
        client_id="xxxxxxxxxxxxxxxxxxxxxxxx",
        client_secret="xxxxxxxxxxxxxxxxxxxxxxxx",
        oauth_code="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        redirect_uri="http://localhost",
    )

api.messages.create(
        "xxxxxxxxxxxxxxxxxxxxxxxxxx",
        text="This is My Message",
    )

This code works, but I have to keep manually generating the 'oauth_code'. Is there a way to automate this with the SDK?

Am I even thinking about this the right way? OAuth is kinda new to me.

Thanks!

 

 

1 Accepted Solution

bunjiega
Level 1
Level 1

So my solution to this was to use a bot token, not OAuth. OAuth is apparently designed to have user interaction and bots are not.

View solution in original post

1 Reply 1

bunjiega
Level 1
Level 1

So my solution to this was to use a bot token, not OAuth. OAuth is apparently designed to have user interaction and bots are not.