I'm very new to working with API's so apologies in advance.
I'm using Postman for testing the EoX API and others. I'm using Get New Access Token to request a token using Grant Type: Authorization Code. I have my application registered on the Cisco API Console and have a Client ID and Client Secret ID. The Cisco OAuth v2.0 Token Developer Guide is a bit confusing (to me) as to which URL's to use for Auth URL and Access Token URL.
Can anyone help clarify this for me?
I am not quite sure how Postman would work using the Auth Code grant type - I never tried to make that work. Auth Code requires a web page (the "Redirection-URL" you entered when you created the app and selected Auth Code) that the token server will redirect the request to once the token is generated. I really don't know how that would play with Postman. Perhaps other experts might chime in.
I typically use the grant type of client credentials when working in Postman. If you are new to API development, client cred is probably the easiest place to start with since it's a two-legged authentication process and is relatively simple. Once you get it working and can use the resulting token to make calls to the APIs, you can then experiment with the other grant types.
But you asked specifically about auth code and the URLs it needs, which really has nothing to do with Postman, so... Your first call is a GET to https://cloudsso.cisco.com/as/authorization.oauth2?response_type=code&client_id=<your client id>.
Once the user logs in, the code that is generated is used in a POST to https://cloudsso.cisco.com/as/token.oauth2 using the code, your client id and client secret. That request would look something like the curl call:
curl -s -k -H "Content-Type: application/x-www-form-urlencoded" -X POST
-d "client_id=<your client id>"
-d "client_secret=<your client sercret>"
-d "code=<the generated code from the previous call>"
-d "redirect_uri=<your redirection url>"
-d "grant_type=authorization_code" https://cloudsso.cisco.com/as/token.oauth2
That should generate the token, which you can then use to make calls to the EOX API.
That helped a lot! I got the Auth Code grant type working using Postman. See below
Using Postman to request EoX information for a Serial Number using Grant type Authorization Code
- Start Chrome and open Postman
- Enter the information as shown below for a request to retrieve EoX info for a given serial number into the appropriate Postman fields:
- Method - Select GET in the Method drop down
- URL -Enter https://api.cisco.com/supporttools/eox/rest/5/EOXBySerialNumber/1/<serial-number>
- Authorization – Select Authorization
- Type: Select OAuth 2.0 from the drop down
- Click Get Net Access Token
- Callback URL - Copy & Paste this URL to your apps Redirection-URL
- Token Name – enter a token name
- Auth URL - https://cloudsso.cisco.com/as/authorization.oauth2
- Access Token URL - https://cloudsso.cisco.com/as/token.oauth2
- Client ID – Your Client ID
- Client Secret – Your client secret
- Grant Type – Auth Code
- Uncheck Request access token locally
- Click Request Token
- Login (if prompted)
- Click Allow
- Existing Tokens - Your token name will show up in the list of existing tokens. Select it see the contents
- Add token to – Select Header and click Use Token
- Click Send.
- Postman will send the request to the server, and the display the response.
- You can see the Response Code that is returned displayed here as '200' and is shown in the Status field.
- You can see the JSON response data that contains the EOX Record.