06-07-2017 01:43 PM
Hello,
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?
Much appreciated.
Regards,
Mark
Solved! Go to Solution.
06-07-2017 05:21 PM
Hi Mark,
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.
HTH,
Keith