谷歌云管理员身份验证



参考以下链接https://cloud.google.com/sql/docs/mysql/admin-api/how-tos/authorizing。我试过了,但没有成功。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"''

由于此请求具有敏感数据(非公共(,因此OAuth令牌和api密钥不是必需的,如本文档所述。

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

相关内容

最新更新