DEngineer
DEngineer

Reputation: 41

How do we retrieve user ID and iam token with below curl request?

As a federated user, it must use an API key or one-time passcode to authenticate. I have tried to execute that the below curl request:-

Example :-

Input :-

curl -s -u 'bx:bx' -k -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d "grant_type=password&response_type=cloud_iam,ims_portal&username=${1}&password=${2}&ims_account=${3}" https://iam.ng.bluemix.net/oidc/token

Output :-

"errorMessage":"You cannot authenticate with user name and password, as you are a federated user","errorDetails":"Your user id '<<><><>>' is federated and must use an API key or one-time passcode to authenticate"

But how we authenticate the user to generate the iam_token and iam_user_id?

Reference :- https://softlayer.github.io/rest/IBMidtoSLKey/

Upvotes: 0

Views: 191

Answers (1)

Van Staub
Van Staub

Reputation: 81

The code snippet you reference from the SoftLayer guide has the result of setting the SoftLayer Username and API key:

echo "SL_USERNAME: $SL_USERNAME"
echo "SL_API_KEY: $SL_API_KEY"

This is a roundabout way to find the same information that is listed as API Username and Authentication Key seen in your User Profile. If you do not see an API username and Authentication Key, you can create one on the Actions menu next to your name in the User List.

You can then execute Infrastructure APIs, which I expect is the ultimate goal.

export IAAS_USERNAME=<API Username>
export IAAS_KEY=<Authentication Key>
curl -u $IAAS_USERNAME:$IAAS_KEY https://api.softlayer.com/rest/v3/SoftLayer_Account/getAllBillingItems

It's unclear if the discussion around IAM tokens is necessary. Please provide more guidance on what you're trying to achieve if the above suggestion is insufficient.

Upvotes: 1

Related Questions