Request a Token without Multi-Factor Authentication

Use the following process if you have not enabled multi-factor authentication on your account.

  1. Send a POST request to the /oauth2/v1/token API.

    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}"
  2. The response body includes an access_token parameter 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_in parameter. The expires_in parameter is configurable.

  3. Export the access token to a variable for convenient use in subsequent requests.

    export ACCESS_TOKEN='YWRtaW4sYWRtaW4sMjAxOC0wOC0wOSAxOToyNzowzVmM2FhNGMzZjMyZDlkNWJmYzg4O'
  4. 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>"