Google Container Engine REST API Authorization

2/25/2015

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

For example for this query:

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

And as mentioned

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

I added it to url:

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

But i have error:

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

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?

-- Suvitruf - Andrei Apanasik
google-authentication
google-kubernetes-engine

1 Answer

3/3/2015

According to the Google help documentation for API Keys (emphasis added):

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.

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.

-- Robert Bailey
Source: StackOverflow