Generate the Access Token

To generate the Access Token, add the Client ID, Client Secret, User Name, and Password using cURL Commands in the CLI Tool. You can use an insecure connection (if you add the --insecure / -k Flag to the cURL command). The following is an example:

curl -k -i -H "Authorization: Basic  < Base64 Encoded
      Outh Cred >" -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8"
      --request POST https://<idcs_tenant>:443/oauth2/v1/token -d
      "grant_type=password&scope=urn:opc:idm:__myscopes__+offline_access&username=<userid>&password=<Password>"

Sample Code

curl -k -i -H "Authorization: Basic YWFpdGVzdGRldjEwMDEtcHJkX0FQUElEOjQyYjJlYWVlLTY1OGEtNDgzYi1hMWI2LTBlYzU0MzBmYWQwNQ==" -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" --request POST https://idcs-0cb0c2b3ba624afca67467fd5eb9db49.identity.c9dev2.oc9qadev.com:443/oauth2/v1/token -d "grant_type=password&scope=urn:opc:idm:__myscopes__+offline_access&username=cneadmin&password=Password@12345"

After generating the Access Token, invoke the API as shown in the following section.

Note:

The Access token expiry (in seconds) is configurable and can be set at the time of generating the access token. In the preceding example, it is set to 3600 seconds ~ 1 hour. By default, the expiry is set to 3600 seconds ~ 1 hour. You can configure this to a value of your choice up to a maximum value of 31536000 seconds ~ 1 year.

The token is sent as a response. Store the token in a secure location.

Sample Access Token (Truncated example)

{"access_token":"eyJ4NXQjUzI1NiI6IlF5azRtb3pIakhuQjJoQnVWdmZXZUpVeVZrNHhUdWd6aWpHSC1pV21xb1EiLCJ4NXQiOiJDRFhHYVlWZXI3STVhQ1l
...
...
DB_be0Rtw1aMxFYg8Ft0VaK14wOVFGhgg1Cr6GiNvbgeYRG5uwgJGqw","token_type":"Bearer","expires_in":3600,"refresh_token":"AgAgYjA1OGVlMjJiMWY2NGU3YWFkM2NjZWNlOTc2MjNiNDgIABBmZRHXpaHil2VBXkevFX-iAAAAMMq9uQDo86eVVVisw3kYn80iX8qRJ2m7hMLmMAh1dY9Wgy-ESu8WYzdTBXOsnwHr7A=="}