"gcloud auth应用程序默认登录"之间的区别和"gcloud auth login" [英] Difference between "gcloud auth application-default login" and "gcloud auth login"
问题描述
gcloud auth application-default login
与gcloud auth login
有什么区别?
尽管有以下定义,仍然很难区分它们.
Despite the definitions below, it is still hard to differentiate them.
gcloud auth应用程序-默认登录名:
-
acquire new user credentials to use for Application Default Credentials
gcloud身份验证登录:
-
authorize gcloud to access the Cloud Platform with Google user credentials
authorize gcloud to access the Cloud Platform with Google user credentials
我什么时候应该使用另一个?
When should I use one over the other?
推荐答案
不同之处在于用例:
作为开发人员,我想通过gcloud与GCP进行交互.
gcloud auth login
这将获取您的凭据并将其存储在~/.config/gcloud/
中.现在,您可以从终端运行gcloud
命令,它将自动找到您的凭据.在这种情况下,任何代码/SDK都会不会自动获取您的信誉.
As a developer, I want to interact with GCP via gcloud.
gcloud auth login
This obtains your credentials and stores them in ~/.config/gcloud/
. Now you can run gcloud
commands from your terminal and it will find your credentials automatically. Any code/SDK will not automatically pick up your creds in this case.
参考: https://cloud.google.com/sdk/gcloud/参考/身份验证/登录
作为开发人员,我希望我的代码通过SDK与GCP交互.
gcloud auth application-default login
这将通过网络流获取您的凭据,并将其存储在应用程序默认凭据的众所周知位置" 中.现在,您运行的任何代码/SDK都将能够自动找到凭据.当您要本地测试通常在服务器上运行并使用服务器端凭据文件的代码时,这是一个很好的替代方法.
As a developer, I want my code to interact with GCP via SDK.
gcloud auth application-default login
This obtains your credentials via a web flow and stores them in 'the well-known location for Application Default Credentials'. Now any code/SDK you run will be able to find the credentials automatically. This is a good stand-in when you want to locally test code which would normally run on a server and use a server-side credentials file.
参考: https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login
编辑(09/19/2019):
正如肯特(Kent)在下面的评论中所做的贡献,"<应用程序默认凭据的众所周知位置" 是位于本地~/.config/gcloud/
目录中的名为application_default_credentials.json
的文件.我在下面的 Theodore Sui 和 Daniel De Leo 的文章中添加了一个附加链接,其中更详细地介绍了差异身份验证方法.
Edit (09/19/2019):
As Kent contributed in his comment below, 'the well-known location for Application Default Credentials' is a file named application_default_credentials.json
located in your local ~/.config/gcloud/
directory. I've added an additional link below to an article by Theodore Sui and Daniel De Leo which goes into greater detail about the difference authentication methods.
文章: https://medium.com/google-cloud /local-remote-authentication-with-google-cloud-platform-afe3aa017b95
这篇关于"gcloud auth应用程序默认登录"之间的区别和"gcloud auth login"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!