ios - Google 自然语言 API 权限被拒绝错误
<p><p>直到昨天,Google Natural Language API 一直在我的 iOS 应用中运行。从今天早上起,API 开始返回“权限被拒绝”错误。例如:</p>
<pre><code>{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
</code></pre>
<p>示例请求:</p>
<pre><code>POST /v1/documents:analyzeEntities?key=..... HTTP/1.1
Host: language.googleapis.com
Content-Type: application/json
Connection: keep-alive
X-Ios-Bundle-Identifier: .....
Accept: */*
Accept-Language: en-us
Content-Length: 291
Accept-Encoding: gzip, deflate
User-Agent: CardScanner/1 CFNetwork/808.2.16 Darwin/15.6.0
{"encodingType":"UTF8","document":{"type":"PLAIN_TEXT","content":"....."}}
</code></pre>
<p>为帐户启用了结算功能(余额为 0 美元)。该帐户还有 36 天的试用期。</p>
<p>键与 Google Cloud Platform API 仪表板中的值匹配。我也尝试过重新生成 key ,并在应用程序中使用新 key 。</p>
<p>我还尝试为 iOS 设备启用 key 限制,并在应用程序包标识符中包含“X-Ios-Bundle-Identifier” header 。</p>
<p>该应用程序还使用 Google Vision API,该 API 可以正常运行。对 Vision API 的调用会响应对关键限制的更改。</p>
<p>来自 <a href="https://cloud.google.com/natural-language/" rel="noreferrer noopener nofollow">demo page</a> 的调用还显示权限错误消息。来自 <a href="https://developers.google.com/apis-explorer/?hl=en_US#p/language/v1/language.documents.analyzeEntities" rel="noreferrer noopener nofollow">API explorer</a> 的电话但是做工作。</p>
<p>编辑:</p>
<p>该错误也发生在 <a href="https://cloud.google.com/natural-language/" rel="noreferrer noopener nofollow">demo on the product web page</a> 上。 .跟踪 Charles 中的错误会显示向网页返回相同的“权限被拒绝”响应:</p>
<p> <a href="/image/JyOdf.png" rel="noreferrer noopener nofollow"><img src="/image/JyOdf.png" alt="enter image description here"/></a> </p>
<p>编辑:</p>
<p>以下是从演示页面捕获的 HTTP 请求和响应的示例。请求和产生的错误几乎与我的应用程序相同,只是演示似乎使用的是 http 2,而我的应用程序使用的是 http 1。</p>
<p>HTTP 请求:</p>
<pre><code>:method: POST
:authority: language.googleapis.com
:scheme: https
:path: /v1/documents:analyzeEntities?key=.....
content-length: 250
origin: https://cloud.google.com
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
content-type: text/plain;charset=UTF-8
accept: */*
referer: https://cloud.google.com/natural-language/
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.8
{"document":{"type":"PLAIN_TEXT","content":"Google, headquartered in Mountain View, unveiled the new Android phone at the Consumer Electronic Show.Sundar Pichai said in his keynote that users love their new Android phones."},"encodingType":"UTF16"}
</code></pre>
<p>HTTP 响应:</p>
<pre><code>:status: 403
vary: Origin
vary: X-Origin
vary: Referer
content-type: application/json; charset=UTF-8
content-encoding: gzip
date: Sun, 26 Feb 2017 14:52:24 GMT
server: ESF
cache-control: private
content-length: 128
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
access-control-allow-origin: https://cloud.google.com
access-control-expose-headers: content-encoding,date,server,content-length
alt-svc: quic=":443"; ma=2592000; v="35,34"
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我们知道这个问题,现在应该修复。如果您仍然遇到同样的问题,请告诉我们。 </p></p>
<p style="font-size: 20px;">关于ios - Google 自然语言 API 权限被拒绝错误,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/42431787/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/42431787/
</a>
</p>
页:
[1]