cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
358
Views
0
Helpful
5
Replies

Can I get a bearer token through the rest api?

mococo
Level 1
Level 1

Is there any option to create or get a webex bearer token by using webex email and password in the nodejs code? Or is it have any other option to get a rest api authentication like Oauth2.0 token???

5 Replies 5

sandiban
Cisco Employee
Cisco Employee

Hi @mococo,
You can use the Webex Integration as documented here to generate Access Token and Refresh Token pair following the OAuth2.0 standard - https://developer.webex.com/docs/integrations
Basically this Webex Integration would provide you the credentials like, OAuth Authorization URL, client_id, client_secret
And, if you use the OAuth Authorization URL in a Browser (better use this URL in private mode of the Browser) and browse through it, you can generate the one time access Code by authenticating yourself using your Webex account.
In the URL section of your Browser, you can find the One time access Code.

Now using all these parameters, you can use the API - https://webexapis.com/v1/access_token and programmatically generate the Access Token & Refresh Token pair.
I've shared a sample screenshot from POSTMAN to show how these parameters could be used to generate the Token in POSTMAN -

sandiban_0-1714722013149.png
Same steps have been documented in the Webex Integration page I referred above as well.

You can implement the same in your Code version as well.
But just using your Webex Username and Password, you can complete this task though. You must need a Integration to get the credentials first.

Hope this helps!

Regards,
Sandip

Hi @sandiban 

   I want to get Token in java, but I can't get the code on the browser.How can I do it? Thank you.

Hi @thisxiaoming,
Actually the code should be generated in the Browser URL section.
Once you run the Integration OAuth Authorization URL in Browser, it should ask you for the Webex Sign-In and once the successful sign-in is complete, it should take you the landing page as per the "redirect_url" value you've set in the Integration settings and once you're on the landing page - kindly check that page URL or, the Browser URL of that page.

May be copy that entire code and paste in a notepad file. You should be able to find a parameter in the URL showing as "code=" as I shared in the attached screenshot.
Please note, in my case my Webex integration "redirect_url" was "https://localhost". 

You should copy the entire "code" value from there and start using it in your /access_token API Request.
Please let us know if you've any further queries.

Regards!
Sandip
Screenshot 2024-06-10 at 11.11.41 AM.png

How to get a code parameter? I can find grant_type, cliend_id, client_secert and redirect_uri option but I don't know where to get a code option.

dtibbe
VIP
VIP

No, you cannot get a token programmatically.

Depending on you app, you have either

* to run the OAuth flow for an integration and the user has to provide it's credentials 

* use the token that was provided during creation for a bot

* use the tokens provided when authorizing a service app during creation.

So what is your use case? Have a look at service apps, maybe that is what you're looking for