具有工作负载身份联合的 Gmail API

发布于 2025-01-16 14:12:30 字数 995 浏览 5 评论 0原文

我与第三方 (auth0) 提供商创建了一个工作负载身份池。我已使用域范围委派配置我的服务帐户,并启用了 GMAIL API。 我可以成功生成 STS 令牌,但在执行邮件客户端时出现错误。 以前使用服务帐户方法时,我曾经提供电子邮件作为主题来委派对服务帐户的访问权限。 由于我使用工作负载身份(以消除密钥),因此我收到错误“前提条件检查失败”。

Workload Identity 联合有哪些限制? 如果我们为用于工作负载身份联合的服务帐户启用了域范围委派,我们可以访问用户数据(邮件/驱动器文件)吗?

我在此处附加片段:

 async function main2(){
     const authClient = google.auth.ExternalAccountClient.fromJSON(jsonConfig);


     authClient.scopes = ['https://www.googleapis.com/auth/gmail.readonly', 
           'https://www.googleapis.com/auth/cloud-platform'];

      const gmail = google.gmail({
         auth: authClient,
         version: 'v1'
       });

      const response = await gmail.users.getProfile({
          userId : '[email protected]'
          });

  console.log(response);
}

JSON 配置包含客户端库配置。 我正在使用 node.js 客户端库。

我的用例是从客户(主要是组织)获取这些配置来访问其用户的工作表、驱动器、电子邮件。

I have created a workload identity pool with a third-party (auth0) provider. I have configured my service account with a domain-wide delegation and have enabled GMAIL API as well.
I could generate STS token successfully but while executing mail client it's giving me an error.
Previously with the service account approach, I used to provide email as subject to delegate access to the service account.
Since I am using workload identity (to eliminate keys), I am getting an error "precondition check failed".

What are the limitations of the Workload Identity federation?
Can we access user data(mail/drive files) if we have enabled domain-wide delegation for the service accounts being used for the Workload identity federation?

I am attaching snippet here :

 async function main2(){
     const authClient = google.auth.ExternalAccountClient.fromJSON(jsonConfig);


     authClient.scopes = ['https://www.googleapis.com/auth/gmail.readonly', 
           'https://www.googleapis.com/auth/cloud-platform'];

      const gmail = google.gmail({
         auth: authClient,
         version: 'v1'
       });

      const response = await gmail.users.getProfile({
          userId : '[email protected]'
          });

  console.log(response);
}

JSON config contains client library config.
I am using the node.js client library.

My use case is to take these configs from clients(mostly orgs) to access sheets, drive, email of their users.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文