I am able to read files in bucket in COS using IAM token but unable to do the same using API key. I have set the following key in my request header:
Authorization: {api key}
Should I set anything else? Note I am not using HMAC credentials. below code has two options one with bearer token and the other with api key created for that Cos instance specifically for the bucket.
example code:
var request = require('request');
//using bearer token
var options = {
uri: 'https://{endpoint}/{bucket name}',
headers: {
'Authorization': 'bearer {token string}',
}
};
//using api key
var options = {
uri: 'https://{endpoint}/{bucketname}',
headers: {
'Authorization': '{{api key string for cos service id}',
}
};
function callback(error, response, body) {
console.log(error)
console.log(response.statusCode)
if (!error && response.statusCode == 200) {
console.log(body)
}
}
request(options, callback);