I tried running the following code on Cloud Container Builder using the npm
builder:
const Storage = require('@google-cloud/storage');
const storage = new Storage();
const bucketName = 'some-bucket-name';
test(`can access GCP`, async (t) => {
await storage
.createBucket(bucketName)
.then(() => {
console.log(`Bucket ${bucketName} created.`);
t.pass();
})
.catch(err => {
console.log(err);
t.fail();
});
});
When I did this, I got a 404 page not found
error. How do I fix this?
In case it helps, I also tried using the Data Loss Prevention API and it gave me an error saying Getting metadata from plugin failed with error: Could not refresh access token.
Thanks!
This was due to a bug in a dependency of google-auto-auth that was fixed as of version 0.9.2
.
Unfortunately, the client libraries (such as @google-cloud/storage
) have not yet been updated to use this version of google-auto-auth
. Until they are updated, you can work around this by overriding transitive dependencies. If you're using yarn
(instead of npm
), add the following section to your package.json
file:
"resolutions": {
"google-auto-auth": "^0.9.2"
}