Got “DatastoreException: Request is missing requir

2019-07-08 08:11发布

On an App Engine application, deployed on standard environment with java 8 activated, I get the exception below if I use both Objectify 6.0 AND the tag <url-stream-handler>urlfetch</url-stream-handler> in the appengine-web.xml file.

com.google.cloud.datastore.DatastoreException: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

Any idea how I can bypass that?

Things get back to normal if I remove the urlfetch tag (and activate the billing) or if I downgrade Objectify to v5.

2条回答
beautiful°
2楼-- · 2019-07-08 08:36

The best option is to use the

<appengine-web-app>
   <url-stream-handler>native</url-stream-handler>
<appengine-web-app>

and enable billing. Without billing you can only use the legacy urlfetch and you have to face all these problems.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-07-08 09:00

I suspect what you're running into is one of the differences between the Java 7 and the Java 8 Standard Environments. There are substantial benefits to avoiding the urlfetch path, as Issuing HTTP(S) Requests notes (e.g. HTTP/2). In particular, the metadata server, which does automatic authentication for the Google Cloud SDKs when running on App Engine, isn't reachable using urlfetch (see that page).

I think your best option here is probably to enable billing, if you're comfortable with that. From the docs page:

Despite the requirement to enable your application for billing, your app won't incur any more cost than the same application running on Java 7.

If you'd still like to give urlfetch a try, I think the error you're encountering can be fixed by manually supplying credentials (e.g. bundling them in your app), but that won't be as secure or performant.

查看更多
登录 后发表回答