[英]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.