java - 当我未登录时,Google 的 API 资源管理器不适用于我的 Google 部署

标签 java google-cloud-endpoints

我有一个 Google 项目 credible-nation-130012,我在其中部署了一个用 Java 编写的应用程序。它使用AppEngine标准环境。唯一的内容是 Google 端点。您可以在 GitHub 上查看源代码:https://github.com/mhdirkse/least-common-multiplier .

虽然没有使用 Google 登录,但我想测试我的部署。为此,我访问了 https://credible-nation-130012.appspot.com/_ah/api/explorer使用火狐浏览器。我的API没有出现。我按 F12 获取开发者信息并看到以下错误:

https://apis-explorer.appspot.com/apis-explorer/?base=https://credible-nation-130012.appspot.com/_ah/api#p/

跨源请求被阻止:同源策略不允许读取 https://accounts.google.com/ServiceLogin?service=ah&passive=true&continue=https://appengine.google.com/_ah/conflogin%3Fcontinue%3Dhttps://credible-nation-130012.appspot.com/_ah/api/discovery/v1/apis 处的远程资源。 (原因:缺少 CORS header “Access-Control-Allow-Origin”)。[了解更多] 跨源请求被阻止:同源策略不允许读取 https://accounts.google.com/ServiceLogin?service=ah&passive=true&continue=https://appengine.google.com/_ah/conflogin%3Fcontinue%3Dhttps://credible-nation-130012.appspot.com/_ah/api/discovery/v1/apis 处的远程资源。 (原因:CORS请求未成功)。[了解更多] 跨源请求被阻止:同源策略不允许读取 https://accounts.google.com/ServiceLogin?service=ah&passive=true&continue=https://appengine.google.com/_ah/conflogin%3Fcontinue%3Dhttps://credible-nation-130012.appspot.com/_ah/api/discovery/v1/apis 处的远程资源。 (原因:缺少 CORS header “Access-Control-Allow-Origin”)。[了解更多] 跨源请求被阻止:同源策略不允许读取 https://accounts.google.com/ServiceLogin?service=ah&passive=true&continue=https://appengine.google.com/_ah/conflogin%3Fcontinue%3Dhttps://credible-nation-130012.appspot.com/_ah/api/discovery/v1/apis 处的远程资源。 (原因:CORS请求未成功)。[了解更多]

然后我关闭了选项卡并访问了 console.cloud.google.com 进行登录。之后我的 API 出现在 https://credible-nation-130012.appspot.com/_ah/api/explorer它起作用了。

我猜测API资源管理器无法正确访问https://accounts.google.com 。它期望返回 header Access-Control-Allow-Origin 但该 header 不存在。这与我的应用程序有什么关系,还是 API 资源管理器中的错误?或者这种行为是谷歌故意的吗?欢迎任何帮助。

谨致问候,

马丁·德克斯

顺便说一句:我正在为工作申请演示这个项目。如果我在这个问题上得到帮助,我会在 GitHub 上明确说明并与可能的雇主沟通。

最佳答案

问题可能出在您的 web.xml 中。您已为所有 URL 设置了管理员身份验证约束,API Explorer 需要访问特定 URL 路径 /_ah/api/discovery/v1/apis (及其下的路径)才能工作。删除约束或放松约束以排除 /_ah/api

关于java - 当我未登录时,Google 的 API 资源管理器不适用于我的 Google 部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52393800/

相关文章:

python - Google 应用程序引擎端点 api python

android - 如何将 Cloud Endpoints 生成的 sources.jar 库移动到 Android 项目中

java - 毕加索不会加载图像 (Android)

java - 我们可以使用模式验证@RequestParam 值吗

android - 为 App Engine 连接的 Android 项目从 Blob 存储迁移到 Google Cloud Storage

android - 无法从 Android 设备连接到谷歌云端点

android - 错误 :Execution failed for task ':backend:appengineEndpointsGetClientLibs

java - 使用 JavaFX 播放 QuickTime 视频

java - 禁止使用 Hibernate Envers 为实体创建 _AUD 表?

java - 将 Eclipse Kepler 仅仅变成一个 XML 编辑器