Got “DatastoreException: Request is missing required authentication credential” if using Objectify 6.0 and <url-stream-handler> at the same time

此生再无相见时 提交于 2019-12-24 03:53: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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/51976220/got-datastoreexception-request-is-missing-required-authentication-credential

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!