【发布时间】:2015-10-09 18:38:54
【问题描述】:
我正在尝试在 Google Cloud 环境中使用来自 PHP App Engine 的 Google Datastore。该过程似乎不像 Cloud Storage 那样无缝,因此我将使用 Datastore REST API。
文档中有一个地方可以向 Datastore API 发出测试请求:https://cloud.google.com/datastore/docs/apis/v1beta2/datasets/lookup#try-it
我遇到的问题是我想在没有 OAuth 的情况下执行此操作(在上面的链接中有一个选项)。但是,当我这样做时,我收到以下错误:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
从请求详细信息中,我看到以下 HTTP 请求签名:POST to https://www.googleapis.com/datastore/v1beta2/datasets/MY_PROJECT_ID/lookup?key={YOUR_API_KEY}。
当我使用来自 Google Cloud“API 和身份验证”凭据的服务器 API 密钥时,我得到了以下信息:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "HTTP Basic Authentication is not supported for this API",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "HTTP Basic Authentication is not supported for this API"
}
}
如果不是服务器密钥,我不太确定在这种情况下 {YOUR_API_KEY} 应该是什么。
如何解决此问题并在没有 OAuth 的情况下访问 Datastore API?
谢谢。
【问题讨论】:
标签: php google-app-engine google-cloud-datastore