0
votes

I am trying to connect to my cloud object storage via nodejs (into node-red). I don't want to use the existing SDK. For simplicity I will use in this question postman/curl. Moreover, the following request should list all my buckets.

Here is my current curl equivalent request (created from postman)

GET / HTTP/1.1
Host: s3.us-south.cloud-object-storage.appdomain.cloud
ibm-service-instance-id: MY INSTANCE ID
Content-Type: text/plain
Authorization: Bearer MYTOKEN
User-Agent: PostmanRuntime/7.13.0
Accept: */*
Cache-Control: no-cache
Postman-Token: POSTMAN TOKEN
Host: s3.us-south.cloud-object-storage.appdomain.cloud
accept-encoding: gzip, deflate
Connection: keep-alive
cache-control: no-cache

But this returns:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
    <Code>AccessDenied</Code>
    <Message>Access Denied</Message>
    <Resource></Resource>
    <RequestId>REQ ID</RequestId>
    <httpStatusCode>403</httpStatusCode>
</Error>

Is there something I am missing? I am refering to this documentation: https://cloud.ibm.com/docs/services/cloud-object-storage/cli?topic=cloud-object-storage-compatibility-api-bucket-operations#compatibility-api-list-buckets

1
How did you obtain the token?data_henrik
@data_henrik via the service credentials tab: prntscr.com/o3s6mgItération 122442

1 Answers

2
votes

You need to obtain an API auth token. For that you need the API key which you already got. See here for how to request the IAM access token. Basically:

curl -X "POST" "https://iam.cloud.ibm.com/identity/token" \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/x-www-form-urlencoded' \
     --data-urlencode "apikey={api-key}" \
     --data-urlencode "response_type=cloud_iam" \
     --data-urlencode "grant_type=urn:ibm:params:oauth:grant-type:apikey"