Google 云管理员身份验证

Google Cloud Admin authentication

参考以下link https://cloud.google.com/sql/docs/mysql/admin-api/how-tos/authorizing。我试过 api 键但没有成功。来自API的回复如下;

//https://www.googleapis.com/sql/v1beta4/projects/<projectid>/instances/<instanceid>/databases?key=<API_KEY>

{
    "error": {
        "code": 401,
        "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
        "errors": [
            {
                "message": "Login Required.",
                "domain": "global",
                "reason": "required",
                "location": "Authorization",
                "locationType": "header"
            }
        ],
        "status": "UNAUTHENTICATED"
    }
}

我对 oAUth 2.0 没有任何问题,因此想确认是否不再支持通过 api 密钥进行授权?

我测试了仅使用 API 密钥从端点获取信息,但无法检索信息,因为必须使用身份验证承载。

我使用这些命令来获取数据库信息

export TOKEN=`gcloud auth application-default print-access-token`

curl -X GET \
  https://sqladmin.googleapis.com/sql/v1beta4/projects/[MY PROJECT ID]/instances/[MY INSTANCE NAME]/databases \
  -H 'authorization: Bearer '"$TOKEN"''

由于此请求包含敏感数据(非 public),因此 OAuth 令牌和 api 密钥不是必需的,如 document.[=12 中所述=]

看来关键参数不再需要了。