我没有登录时,Google的API资源管理器无法用于我的Google部署

问题描述 投票:0回答:2

我有一个Google项目可靠 - 国家 - 130012,我部署了一个用Java编写的应用程序。它使用AppEngine标准环境。唯一的内容是Google端点。你可以在GitHub看到来源:https://github.com/mhdirkse/least-common-multiplier

虽然没有登录谷歌,但我想测试我的部署。为此,我使用Firefox访问了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标题'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标题'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。它希望得到一个标题Access-Control-Allow-Origin但不存在。这与我的应用程序有什么关系,还是API浏览器中的错误?或者谷歌是否有这种行为?欢迎任何帮助。

亲切的问候,

Martijn Dirkse

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

java google-cloud-endpoints
2个回答
1
投票

这个问题可能在你的web.xml。您已为所有URL设置了admin auth约束,并且API Explorer需要访问某个URL路径/_ah/api/discovery/v1/apis(及其下的路径)才能工作。删除约束或松开约束以排除/_ah/api


0
投票

我在web.xml中有一个安全约束,如下所示:

<security-constraint>
  <web-resource-collection>
    <web-resource-name>all</web-resource-name>
    <url-pattern>/*</url-pattern>
  </web-resource-collection>
  <auth-constraint>
    <role-name>admin</role-name>
  </auth-constraint>
  <user-data-constraint>
    <transport-guarantee>CONFIDENTIAL</transport-guarantee>
  </user-data-constraint>
</security-constraint>

我认为这是错误。这表示URL credible-nation-130012.appspot.com/_ah/api/explorer需要“管理员”角色。但访问端点API的远程应用程序不是管理员。放置这个安全约束似乎是无稽之谈。

限制访问我的API也不重要。这是一个我想展示的玩具项目。

我已经看到,退出后,它需要一段时间才能生效。我明天会检查我的应用程序是否符合预期。

我现在不再需要帮助了。

© www.soinside.com 2019 - 2024. All rights reserved.