本文介绍了得到"DatastoreException:请求缺少必需的认证凭证".如果使用Objectify 6.0和< url-stream-handler>同时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在App Engine应用程序上,该应用程序部署在激活了Java 8的标准环境中,如果同时使用Objectify 6.0和appengine-web.xml文件中的标记<url-stream-handler>urlfetch</url-stream-handler>,则会出现以下异常.

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?

如果我删除urlfetch标签(并激活账单)或将Objectify降级到v5,一切都会恢复正常.

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

推荐答案

我怀疑您遇到的是Java 7和Java 8 Standard Environments之间的差异之一.避免使用urlfetch路径有很多好处,因为发出HTTP( S)请求注释(例如HTTP/2).特别是,使用urlfetch(请参见该页面)无法访问元数据服务器,该元数据服务器在App Engine上运行时会对Google Cloud SDK进行自动身份验证.

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:

如果您仍然想尝试urlfetch,我认为您可以通过手动提供凭据(例如,将其捆绑在您的应用程序中)来解决所遇到的错误,但这不会那么安全或表演者.

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.

这篇关于得到"DatastoreException:请求缺少必需的认证凭证".如果使用Objectify 6.0和&lt; url-stream-handler&gt;同时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 12:11