是否可以以编程方式从启用了 api 的服务帐户凭据中检索? (在nodejs中,不是云环境中)

发布于 2025-01-15 05:57:44 字数 154 浏览 3 评论 0原文

我有一个带有 client_email 和 private_key 的服务帐户凭据 json 文件。 那么是否可以以编程方式从服务帐户凭据中检索启用了哪些 api?我指的不是像访问 console.cloud.google.com 这样的解决方案,而是来自 Nodejs 内部的解决方案。谢谢!

I have a service account credentials json file with client_email and private_key.
Is it then possible to programmatically retrieve from serviceaccount credentials which api's are enabled? I don't mean a solution like go to console.cloud.google.com but from within nodejs. Thanks!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝颜夕 2025-01-22 05:57:44

您还需要知道项目 ID。 @wardenunleashed 的答案是针对 API 网关的。这不包括启用哪些 Google API。

API 是按项目启用的,因此您必须指定要查询的项目。

服务帐户 JSON 密钥文件包含拥有服务帐户的项目的项目 ID。

private_key_id 也很重要。该 ID 用于查找公钥以验证私钥签名。

You will need to know the Project ID as well. The answer from @wardenunleashed is for API Gateway. That does not cover which Google APIs are enabled.

APIs are enabled per project, so you must specify the project to query.

A service account JSON key file contains the Project ID for the project that owns the service account.

The private_key_id is also important. That ID is used to lookup the public key for validating private key signatures.

南风几经秋 2025-01-22 05:57:44

Google 有一个适用于 NodeJS 的 API 网关客户端库,具有所需的功能

const projectId = 'my-project';
const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway');
const client = new ApiGatewayServiceClient();
async function listApis() {
  const [apis] = await client.listApis({
    parent: `projects/${projectId}/locations/global`,
  });
  for (const api of apis) {
    console.info(`name: ${api.name}`);
  }
}
listApis();

Google has an API Gateway Client Library for NodeJS with the desired capability

const projectId = 'my-project';
const {ApiGatewayServiceClient} = require('@google-cloud/api-gateway');
const client = new ApiGatewayServiceClient();
async function listApis() {
  const [apis] = await client.listApis({
    parent: `projects/${projectId}/locations/global`,
  });
  for (const api of apis) {
    console.info(`name: ${api.name}`);
  }
}
listApis();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文