You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Node.js获取Google Cloud服务账号:是否选错客户端、文档或版本?

Node.js获取Google Cloud服务账号详情的正确方式

你并没有选错方向,但大概率是找错了Node.js对应的客户端文档或包。

  • Node.js中获取服务账号详情的功能,是通过@google-cloud/iam-admin这个专门的IAM Admin客户端包实现的,而非你查阅的基础IAM模块文档。
  • 具体实现步骤:
    1. 安装客户端包:
    npm install @google-cloud/iam-admin
    
    1. 使用IAMClient的getServiceAccount方法查询详情,示例代码:
    const { IAMClient } = require('@google-cloud/iam-admin');
    
    async function fetchServiceAccountDetails() {
      const client = new IAMClient();
      // 替换为你的项目ID和服务账号邮箱
      const resourceName = 'projects/你的项目ID/serviceAccounts/服务账号邮箱';
      const [serviceAccount] = await client.getServiceAccount({ name: resourceName });
      console.log('服务账号详情:', serviceAccount);
    }
    
    fetchServiceAccountDetails().catch(console.error);
    
  • 版本注意事项:确保安装的是最新版的@google-cloud/iam-admin,避免因版本过低导致功能缺失。

内容的提问来源于stack exchange,提问作者Oli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 07:04:48