Google Container Engine REST API授权 [英] Google Container Engine REST API Authorization

查看:85
本文介绍了Google Container Engine REST API授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处所述,我创建了使用集群操作.

As mentioned here I created API key for using cluster operations.

例如此查询:

https://www.googleapis.com/container/v1beta1/projects/PROJECT_ID/clusters

并且如上所述

拥有API密钥后,您的应用程序可以追加查询 所有请求网址的参数key = yourAPIKey.

After you have an API key, your application can append the query parameter key=yourAPIKey to all request URLs.

我将其添加到了网址:

https://www.googleapis.com/container/v1beta1/projects/PROJECT_ID/clusters?key = my_key

但是我有错误:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "required",
    "message": "Login Required",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Login Required"
 }
}

我什至试图将密钥添加到标头的Authorization部分...并出现以下错误:

I even tried to add key to Authorization part of header...and had this error:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "authError",
    "message": "Invalid Credentials",
    "locationType": "header",
    "location": "Authorization"
   }
  ],
  "code": 401,
  "message": "Invalid Credentials"
 }
}

哪里有问题?还是我出了什么问题?

Where is problem? Or did i something wrong?

推荐答案

根据有关API密钥的Google帮助文档(强调):

API密钥(服务器密钥或浏览器密钥)是唯一的 您使用开发者控制台生成的标识符.使用 API密钥不需要用户采取任何行动或征得用户的同意. API密钥不授予 访问任何帐户信息,并且不用于 授权.

An API key (either a server key or a browser key) is a unique identifier that you generate using the Developers Console. Using an API key does not require user action or consent. API keys do not grant access to any account information, and are not used for authorization.

此外,它表示可以将它们用于访问Google服务公开或拥有的数据. Google容器群集(GKE)数据都不是.我不确定文档为什么建议使用API​​密钥,但是我知道OAuth可以工作,因此,如果可以使用OAuth,则应该可以使REST API正常工作.

Furthermore, it says that they can be used to access data that is public or owned by a Google service. The Google Container Clusters (GKE) data is neither of these. I'm not sure why the documentation suggests using an API key, but I know that OAuth works so if you can use that instead you should be able to get the REST API working.

这篇关于Google Container Engine REST API授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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