nodejs-storage
nodejs-storage copied to clipboard
how to access storage with impersonated token?
Hello, I am trying to create signed url by using impersonated account token but I am getting error: Error: Cannot sign data without client_email.
how i create impersonated token:
const googleAuth = new GoogleAuth({
keyFilename: 'key.json',
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
const client = await googleAuth.getClient();
let targetClient = new Impersonated({
sourceClient: client,
targetPrincipal:
'impersonated-account@*.iam.gserviceaccount.com',
lifetime: 300,
delegates: [],
targetScopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
const token = await targetClient.getAccessToken();
then I am creating storage client and trying to get signed url:
const storage = new Storage({
token: token.token!,
});
const options = {
version: 'v4',
action: 'read',
expires: Date.now() + 15 * 60 * 1000, // 15 minutes
} satisfies GetSignedUrlConfig;
const [url] = await storage
.bucket('local-art-publisher')
.file('test.txt')
.getSignedUrl(options);
Hi @da1z please see https://github.com/googleapis/nodejs-storage/issues/2381 which may be of assistance.
Wanted to check if you were able to resolve this issue @da1z?
Going to close this out. If there are additional questions, please feel free to reopen.