I'm having an problem to specify an access token for authorize my call while using the nodejs client api.
const gcs = require('@google-cloud/storage')({
projectId: 'my-project'
});
gcs.interceptors.push({
request: (requestOptions) => {
requestOptions.headers = requestOptions.headers || {};
requestOptions.headers['Authorization'] = 'Bearer ' + token.access_token; // it's a string
return requestOptions;
}
});
const bucket = gcs.bucket('my-buckuet');
bucket.interceptors.push({
request: (requestOptions) => {
requestOptions.headers = requestOptions.headers || {};
requestOptions.headers['Authorization'] = 'Bearer ' + token.access_token;
return requestOptions;
}
});
bucket.exists((err, exists) => {
if (err) {
console.log(err);
} else {
console.log(exists);
}
});
I've this error ==> Error: invalid_grant
I try to directly call the API with, postman setting the Authorization header using my generated access token and it works. I don't know how to force the authorization header in the request. any help?
Diego
via Diego Molteni
No comments:
Post a Comment