简体   繁体   English

如何使用服务帐户文件向GCP API进行身份验证

[英]How to authenticate to GCP API with service account file

I am new user to GCP. 我是GCP的新用户。 I starting to implement an application that is going to use GCP API. 我开始实现将要使用GCP API的应用程序。 In order to authenticate to API I've created service account and stored it in file. 为了向API进行身份验证,我创建了服务帐户并将其存储在文件中。 In official documentation it is written that auth file can be assigned to environment variable: GOOGLE_APPLICATION_CREDENTIALS I would like to make a request to google API from my http client (let's say Postman) and to use this file for authentication. 在官方文档中写道,可以将auth文件分配给环境变量:GOOGLE_APPLICATION_CREDENTIALS我想从我的http客户端(例如Postman)向google API发出请求,并使用该文件进行身份验证。

Is it possible at all or I suppose to use GCP client in order to make HTTP requests? 我是否可以使用GCP客户端发出HTTP请求?

Yes, you can create an authenticate API key, and use that API key to call GCP API. 是的,您可以创建一个身份验证API密钥,然后使用该API密钥来调用GCP API。 Here is the doc for Creating and Using API key . 这是创建和使用API​​密钥的文档。

Also, you need to be careful not to expose your API keys to the public, like Github. 另外,您需要注意不要将您的API密钥公开给公众,例如Github。 Because we have seen many people just write their API key directly in the code and expose to the public. 因为我们已经看到很多人只是直接在代码中编写他们的API密钥,然后向公众公开。

As you said, you would like to use the API key in HTTP request, maybe you should add restrictions to your keys. 如您所说,您想在HTTP请求中使用API​​密钥,也许您应该对密钥添加限制

Here are some best practices that Google provided, hope this helps! 以下是Google提供的一些最佳做法 ,希望对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google 翻译 API V3:如何从文件流中验证服务帐户 - Google translate API V3: How to authenticate service account from file stream 如何通过 Apps 脚本验证服务帐户以调用 GCP 云 Function - How Do I Authenticate a Service Account via Apps Script in order to Call a GCP Cloud Function GCP 使用 gcloud auth(不是服务帐户)以最终用户身份进行身份验证 - GCP Authenticate as End User using gcloud auth (not service account) 如何使用服务帐户从共享驱动器 GCP 导出文件 - How to export file from shared drive GCP using service account gcp - 如何在没有密钥文件的情况下将 Python 应用程序作为服务帐户运行 - gcp - how to run Python application as Service Account without a key file 如何将 GCP IAM 角色添加到服务帐号 - How to add GCP IAM roles to Service Account 如何恢复 GCP 项目服务帐号 - How to recover GCP project service account 如何使用 Terraform 将自定义 GCP 角色附加到 GCP 服务帐户 - How to Attach Custom GCP Role to a GCP Service Account Using Terraform 如何验证谷歌服务帐户凭据 - How to authenticate google service account credentials 如何使用python API从GCP服务帐户以编程方式生成kubernetes配置 - How to programmatically generate kubernetes config from GCP service account using python API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM