0

我正在尝试使用此文档自动验证谷歌业务通信的代理。我生成 auth_code 并通过与谷歌服务器交换它来获取访问令牌但是当尝试请求验证代理时在请求中收到此错误错误由于身份验证错误无法自动验证我的请求代理验证代码

async function verifyAgent(agentName){
  const test="XXXX"
  const oAuth2Client = new google.auth.OAuth2(
      "XXXXXXX",
      "XXXXXXXXX",
      "postmessage"
  );
  google.options({auth: oAuth2Client});
  const authorizeUrl = oAuth2Client.generateAuthUrl({
    access_type: 'offline',
    scope: "https://www.googleapis.com/auth/businesscommunications",
  });
  const {tokens} = await oAuth2Client.getToken(test);
  let bcApi = new businesscommunications.businesscommunications_v1.Businesscommunications({});
  const scopes = [
    'https://www.googleapis.com/auth/businesscommunications',
    "https://www.googleapis.com/auth/business.manage",
  ];
  oAuth2Client.setCredentials(tokens);
  const agentVerificationContact = {
    agentVerificationContact: {
      partnerName: 'XXXX',
      partnerEmailAddress: 'XXXXXX',
      brandContactName: 'XXXXXXX',
      brandContactEmailAddress: 'XXXXXX',
      brandWebsiteUrl: 'XXXXXXXXXX',
    },
  };
  const apiParams = {
    auth: oAuth2Client,
    name: agentName,
    resource: agentVerificationContact
  };
  bcApi.brands.agents.requestVerification(apiParams, {}, (err, response) => {
    if (err !== undefined && err !== null) {
      console.dir(err);
    } else {
      console.log(response.data);
    }
  });

}

请帮助谢谢

4

0 回答 0