在没有 gcloud 的情况下获取服务帐户身份验证令牌? [英] Get service account auth token without gcloud?

查看:31
本文介绍了在没有 gcloud 的情况下获取服务帐户身份验证令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不使用 gcloud 的情况下获得 Google Cloud 服务帐户的授权不记名令牌?

Is it possible to get an authorization bearer token for a Google Cloud service account without the use of gcloud?

也就是说,我想发出一个 HTTP 请求(大概是由我的 JSON 密钥文件以某种方式签名),它将为我提供相当于

That is, I would like to make an HTTP request (presumably signed in some way by my JSON key file) that would provide me the equivalent of

gcloud auth application-default print-access-token

此请求将在我自己的服务器上发出,我可能不希望在其中安装 gcloud 并且我无权访问可能提供此功能的任何内部服务器元数据(例如,Compute Engine 的情况).

This request would be made on my own server, where I may not wish to install gcloud and where I do not have access to any internal server metadata that might provide this (e.g., as is the case with Compute Engine).

是否有一些 oauth 端点提供类似的功能?

Is there some oauth endpoint that provides something like this?

或者,是否有某种方法可以使用 gcloud 生成长期存在的令牌?

Alternately, is there some way to generate long-lived tokens with gcloud?

我是 Google Cloud 生态系统的新手,请原谅我的无知和术语...

I'm new to the Google Cloud ecosystem, so excuse my ignorance and terminology...

推荐答案

我认为这正是您要寻找的:

I think that this is exactly what you are looking for:

https://developers.google.com/identity/protocols/OAuth2#serviceaccount

老实说,我不认为你试图实现的目标是正确的,运行

Honestly I don't think that what you were trying to achieve was correct, running

gcloud auth application-default print-access-token

您获得的令牌并非用于执行您想要的操作:

you get a token that is not intended to do what you were looking for:

当您开发的代码通常使用服务帐户但需要在更容易提供用户凭据的本地开发环境中运行代码时,此命令很有用."

"This command is useful when you are developing code that would normally use a service account but need to run the code in a local development environment where it's easier to provide user credentials."

这应该会指导您更多地实施此解决方案:https://developers.google.com/identity/protocols/OAuth2ServiceAccount

This should guide you a bit more in the implementation of this solution: https://developers.google.com/identity/protocols/OAuth2ServiceAccount

这篇关于在没有 gcloud 的情况下获取服务帐户身份验证令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆