2

Google Natural Language API has been working in my iOS app up until yesterday. The API started returning "permission denied" errors as of this morning. E.g:

{
    "error": {
        "code": 403,
        "message": "The caller does not have permission",
        "status": "PERMISSION_DENIED"
    }
}

Example request:

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":"....."}}

Billing is enabled for the account (with a balance of $0). The account also has 36 days left on the trial period.

The key matches the value in the Google Cloud Platform API dashboard. I have also tried regenerating the key, and using the new key in the app.

I have also tried enabling key restrictions for iOS devices, and included the "X-Ios-Bundle-Identifier" header with the app bundle identifier.

The app also uses the Google Vision API which works without issues. Calls to the Vision API do respond to changes to the key restrictions.

Calls made from the demo page also show a permissions error message. Calls from the API explorer do work however.

Edit:

The error is also happening on the demo on the product web page. Tracing the error in Charles shows the same "permission denied" response being returned to the web page:

enter image description here

Edit:

Below is an example of the HTTP request and response captured from the demo page. The request and resulting error is almost identical to my app, except that the demo seems to be using http 2, whereas my app is using http 1.

HTTP request:

: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"}

HTTP response:

: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"
  }
}
Luke Van In
  • 5,215
  • 2
  • 24
  • 45

3 Answers3

3

We are aware of this issue and should be fixed now. Let us know if you still see the same problem.

1

I have experienced the same behaviour and I believe it is an undocumented change at Google's end.

I can now only make the call work via OAuth, despite the documentation suggesting that an API key is sufficient. Up until very recently it was possible to make a call with an API key only and no restrictions configured on the key.

My "answer" for what it's worth is to provide feedback on the documentation page to complain that the documentation doesn't match the behaviour. I think the wording on the page may have changed recently, but it still suggests an API key should work for testing purposes.

sahmeepee
  • 378
  • 2
  • 8
  • This seems to be a reasonable conclusion. Were you able to access the API using OAuth from a web page / iOS app? As I understand it, OAuth is intended to be used from a back-end server, as it requires including a super-secret private key (or something along those lines). – Luke Van In Feb 27 '17 at 13:52
  • On further investigation, OAuth can be used without super-secret info. The AppAuth library looks useful: https://openid.github.io/AppAuth-iOS/ – Luke Van In Feb 27 '17 at 15:54
  • As per the comment from @Apoorv Saxena below this is now working – sahmeepee Feb 28 '17 at 08:33
0

"TRY NATURAL LANGUAGE API" button from Google Cloud Vision API demo page doesn't work either! Looks like some bug, hope they fix it soon...

Natural Language API progress indefinite loop

miranido
  • 120
  • 1
  • 4