Request a Token without Multi-Factor Authentication
Use the following process if you have not enabled multi-factor authentication on your account.
-
Send a POST request to the
/oauth2/v1/tokenAPI.curl -L -X POST "${IDCS_FQDN}/oauth2/v1/token" \ --header "Authorization: Basic ${AUTHORIZATION_VALUE}" \ --header "Content-Type: application/x-www-form-urlencoded" \ --data-urlencode "scope==osdmc:rest offline_access" \ --data-urlencode "grant_type=password" \ --data-urlencode "password=${PASSWORD}" \ --data-urlencode "username=${USERNAME}" -
The response body includes an
access_tokenparameter that contains the access token.{ "access_token": <generated_access_token>, "token_type": "Bearer", "expires_in": 3600, "refresh_token": <refresh_token> }The token expires after the number of seconds given in the
expires_inparameter. Theexpires_inparameter is configurable. -
Export the access token to a variable for convenient use in subsequent requests.
export ACCESS_TOKEN='YWRtaW4sYWRtaW4sMjAxOC0wOC0wOSAxOToyNzowzVmM2FhNGMzZjMyZDlkNWJmYzg4O' -
Use the access token in the Authorization header for all subsequent calls to the APIs.
curl -L -X GET \ --header "Authorization: Bearer ${ACCESS_TOKEN}" \ "https://<tenant-url>/<tenant-name>/<path-to-resource>"