Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 获得;调用者没有权限“;当尝试更新Blinginfo时_Node.js_Google Cloud Platform_Google Cloud Billing - Fatal编程技术网

Node.js 获得;调用者没有权限“;当尝试更新Blinginfo时

Node.js 获得;调用者没有权限“;当尝试更新Blinginfo时,node.js,google-cloud-platform,google-cloud-billing,Node.js,Google Cloud Platform,Google Cloud Billing,我正在尝试以编程方式更新我的一个项目的帐单帐户。我正在使用googleapis REST的节点客户端库。这是我的代码: const { google } = require('googleapis'); const cloudbilling = google.cloudbilling('v1'); async function main() { let authClient; try { authClient = await authorize(); console.lo

我正在尝试以编程方式更新我的一个项目的帐单帐户。我正在使用googleapis REST的节点客户端库。这是我的代码:

const { google } = require('googleapis');
const cloudbilling = google.cloudbilling('v1');
async function main() {
  let authClient;
  try {
    authClient = await authorize();
    console.log('AUTH', authClient);
  } catch (err) {
    console.error(err);
  }
  const request = {            
      name: "projects/rensi-28",   
      requestBody: {
        billingAccountName: "billingAccounts/My Billing Account" 
      }    
           
  };
  google.options({auth: authClient});
  try {
    const response = (await cloudbilling.projects.updateBillingInfo(request)).data;    
    console.log(JSON.stringify(response, null, 2));
  } catch (err) {
    console.error('error:', err);
  }
  
}
main();

async function authorize() {
  const auth = new google.auth.GoogleAuth({
    scopes: ['https://www.googleapis.com/auth/cloud-platform']
  });
  return await auth.getClient();
}
这是我得到的错误:

errors: [
    {
      message: 'The caller does not have permission',
      domain: 'global',
      reason: 'forbidden'
    }
  ]
我使用的是服务帐户,环境变量设置正确,因为我可以创建项目和使用其他API

我的服务帐户具有以下角色:

水平仪 角色 项目 项目计费经理 项目 所有者 组织机构 帐单帐户管理员 组织机构 帐单帐户创建者 组织机构 项目计费经理 组织机构 帐单帐户查看器 组织机构 所有者 负责公司的开单业务 帐单帐户管理员 负责公司的开单业务 计费帐户用户 负责公司的开单业务 帐单帐户查看器
billingAccountName
的格式不正确

使用
billingAccounts/45FG32-45FG32-45FG32
格式


参考:。

参数名称不清楚,请尝试使用

项目id而不是项目名称 使用计费帐户id代替计费帐户名称

const request = { 
      name: "projects/rensi-28",   // projectId
      requestBody: {
        billingAccountName: "billingAccounts/My Billing Account" //billingAcountId
      }    
           
  };

谢谢,账单账户名称和项目id不正确是的,我使用的是项目名称和账单账户名称,需要项目id和账单账户id