Google API密钥是否适用于Prediction API?

时间:2014-11-13 17:15:26

标签: google-api google-api-python-client google-prediction

我正按照https://developers.google.com/console/help/new/#generatingdevkeys

中的说明尝试使用服务器API密钥

我已经生成了一个密钥并将我的IP列入白名单(到目前为止已尝试过两种不同的IP)。

但是,我发送的每个回复都会导致401 Unauthorized。我的HTTP请求如下所示:

来自与密钥相关联的IP的请求

POST https://www.googleapis.com/prediction/v1.6/projects/652546152834/hostedmodels/website/predict?key={MY_API_KEY_IS_HERE} HTTP/1.1
User-Agent: Fiddler
Host: www.googleapis.com
Content-Length: 0

响应

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

我错过了一步吗?我不想使用OAuth,因为对于我的简单场景来说它似乎有点过头了,但是如果这里没有解决方案我会做下一步。

1 个答案:

答案 0 :(得分:1)

  

您的应用程序必须使用OAuth 2.0来授权请求​​。不支持其他授权协议。

Source