无法访问本地主机上的API资源管理器。

时间:2021-10-18 23:14:07

I'm trying to build an Endpoints application, but am new to Google App Engine.

我正在尝试构建一个端点应用程序,但是对于谷歌应用程序引擎来说是新的。

As I understand it, there's some kind of API Explorer included in the SDK that should let me test/verify my API -- the docs say: "Test the API backend in the Google APIs Explorer by navigating to http://localhost:8080/_ah/api/explorer". But I can't find any documentation of what API Explorer actually is, does, or looks like.

正如我所理解的,在SDK中包含了某种API资源管理器,它应该允许我测试/验证我的API——文档说:“通过导航到http://localhost:8080/_ah/ API / Explorer,在谷歌API Explorer中测试API后端。”但是我找不到任何API资源管理器的文档。

In any case, when I try to hit that URL, I get immediately redirected to https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/, which tells me nothing useful, and seems like it must be an error of some kind.

在任何情况下,当我试图点击那个URL时,我都会立即被重定向到https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/,它告诉我没有什么有用的东西,并且看起来一定是某种错误。

The devappserver logs say:

devappserver日志说:

INFO     2013-07-17 17:27:54,574 server.py:593] default: "GET /_ah/api/explorer HTTP/1.1" 302 -
INFO     2013-07-17 17:27:56,099 server.py:593] default: "GET /_ah/api/static/proxy.html?jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.7JUwNUXMAS8.O%2Fm%3D__features__%2Fam%3DEQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAItRSTO0dpKS_pssf5r3z87E6FlFvDGdOg HTTP/1.1" 200 1933
INFO     2013-07-17 17:27:56,193 server.py:593] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 2342
INFO     2013-07-17 17:27:56,492 server.py:593] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 200 576
INFO     2013-07-17 17:27:56,507 server.py:593] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 2342
INFO     2013-07-17 17:27:56,583 server.py:593] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 2342
INFO     2013-07-17 17:27:56,811 server.py:593] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 200 576
INFO     2013-07-17 17:27:56,886 server.py:593] default: "GET /_ah/api/discovery/v1/apis/scrnxSync/v1/rest HTTP/1.1" 200 3365

for whatever that's worth.

任何的价值。

Here's my app.yaml:

这是我的app.yaml:

application: scrnx-cloud-1
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /admin/.*
  script: admin.application
  login: admin
  secure: always

  # Endpoints handler
- url: /_ah/spi/.*
  script: sync_api.application

  # catchall - must come last    
- url: /.*
  script: default.application


admin_console:
  pages:
  - name: View Measurement
    url: /admin/measurement  


libraries:
- name: jinja2
  version: 2.6
- name: markupsafe
  version: 0.15

builtins:
- admin_redirect: off
- appstats: off
- deferred: off
- remote_api: on

Is there something else I'm supposed to be doing to set this up?

我还需要做些什么来设置这个吗?

11 个解决方案

#1


4  

The URL for the API Explorer is correct, but there have been some issues (apparently not all resolved) where the API Explorer doesn't correctly list your APIs.

API资源管理器的URL是正确的,但是有一些问题(显然不是全部解决),API资源管理器没有正确地列出您的API。

As comparison of how it should look like https://developers.google.com/apis-explorer/ is the API Explorer for Google APIs, far more APIs than you would normally host yourself, but just to give you an idea of what you should see: a list of APIs and details for each API once you click on it.

如何应该类似于https://developers.google.com/apis-explorer/的比较是Google的API浏览器API,API远比你通常会主持人自己,只是给你一个想法,你应该看到:为每个API列表API和细节一旦你点击它。

A workaround that usually worked is to explicitly add the name and version of your API to the URL, so since your API is called scrnxSync with version v1 this link should show you the methods you defined for your API, and allow you to call those methods:

通常工作的一种方法是显式地将API的名称和版本添加到URL中,因此,由于您的API被称为“scrnxSync”,而vv1这个链接应该向您显示您为API定义的方法,并允许您调用这些方法:

https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/scrnxSync/v1/

https://developers.google.com/apis-explorer/?base=http:/ / localhost:8080 / # p / scrnxSync _ah / api / v1 /

#2


8  

Something changed, and now you must start Chrome in a specific way to use api explorer on localhost development server

有些事情发生了变化,现在您必须以一种特定的方式启动Chrome,以在本地主机开发服务器上使用api explorer。

here is a link to info from google.

这里是一个从谷歌的信息链接。

But for me it still didn't fix using api explorer with localhost dev server.
I find that a possible workaround is to launch Chrome with the flag "--allow-running-insecure-content"
On MacOs in terminal run this:

但对我来说,它仍然没有使用localhost开发服务器来修复api资源管理器。我发现一个可能的解决方案是在终端运行的MacOs上使用“允许运行不安全”的标志来启动Chrome:

/Applications/Google\ Chrome.app/Contents/Mac/Google\ Chrome --user-data-dir=test --allow-running-insecure-content

/应用程序/谷歌\ Chrome。应用程序/内容/ Mac /谷歌\ Chrome——测试——allow-running-insecure-content user-data-dir =

#3


7  

If you are using Chrome browser, just make https in the URL to http. It worked for me.

如果您使用的是Chrome浏览器,请在URL中使用http。它为我工作。

http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/

http://apis-explorer.appspot.com/apis-explorer/?base=http:/ / localhost:8080 / _ah / api # p /

#4


4  

I tried all of the above in chrome and nothing works for me, but using firefox I just click in the lock at the left of the url bar and disable the security. That made the trick for me, cheers !! :D

我在chrome上尝试了以上所有操作,但没有任何效果,但使用firefox时,我只在url栏左边的锁上单击,然后禁用安全性。这对我来说是一种技巧,干杯!!:D

#5


3  

A quick fix: Open the link: http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/ in firefox , then click the secure connection icon on the nav bar, then click disable protection. You should be able to see your APIs

快速修复:打开链接:http://apis-explorer.appspot.com/apis-explorer/?在firefox中,单击安全连接图标,然后单击禁用保护。您应该能够看到您的api。

ps; Remember to edit 8080 with your port number

ps;记得用您的端口号编辑8080。

#6


2  

I'm also new to GAE Endpoints, and I had the same problem. In my case, I had this error because of the order of the url handlers in the app.yaml. I had it like this:

我对GAE端点也是新的,我也有同样的问题。在我的例子中,我有这个错误,因为app.yaml中url处理程序的顺序。我是这样的:

- url: /.*
  script: core_service.application

  # Endpoints handler
- url: /_ah/spi/.*
  script: api_service.application

The right way is defining first the most specific routes and at the end the most general (/.*). Like this:

正确的方法是先定义最具体的路线,最后确定最一般的路线(/。*)。是这样的:

  # Endpoints handler
- url: /_ah/spi/.*
  script: api_service.application

- url: /.*
  script: core_service.application

#7


2  

I know it is not exactly the same problem but I was having the message "You are exploring an API that is described or served via HTTP instead of HTTPS. This is insecure and may be blocked by your browser. To fix this, set up a TLS proxy for your API. Alternatively, you can tell your browser to allow active content via HTTP at this site (on Chrome, click the shield in the URL bar), but this will not improve security or dismiss this message."

我知道这并不是完全相同的问题,但我有一个消息:“您正在探索一个通过HTTP而不是HTTPS来描述或服务的API”。这是不安全的,可能会被浏览器阻塞。要修复这个问题,请为您的API设置一个TLS代理。或者,你可以告诉你的浏览器允许在这个站点上通过HTTP进行活动内容(在Chrome上,点击URL栏中的屏蔽),但是这不会提高安全性或者忽略这个消息。

Clicking the shield icon in the address bar of Chrome did it for me.

在Chrome的地址栏中点击“屏蔽”图标就可以了。

#8


1  

If you are running the AppEngine from GWT DevMode you need to change port in the base parameter to match what you see in console, for me that's 8888:

如果您从GWT DevMode运行AppEngine,您需要在基本参数中更改端口,以匹配您在控制台上看到的内容,对我来说是8888:

http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8888/_ah/api#p/

http://apis-explorer.appspot.com/apis-explorer/?base=http:/ / localhost:8888 / _ah / api # p /

#9


0  

For me, it is a very simple typo in app.yaml. If you have the same problem, it can be just this simple:

对我来说,这是一个非常简单的错误。如果你有同样的问题,可以这么简单:

Instead of (which is correct):

而不是(这是正确的):

- url: /_ah/spi/.*
  script: services.application

I put:

我把:

- url: /_ah/api/.*
  script: services.application

Changing api back to spi did the trick.

改变api回到spi做了这个魔术。

#10


0  

The problem is that your python file can't find the import for:

问题是您的python文件无法找到:

from protorpc import remote

Therefore use the terminal, skip the GUI, navigate to the appengine sdk directory and put your project in there. For mac it is:

因此,使用终端,跳过GUI,导航到appengine sdk目录,并将您的项目放入其中。对于mac:

/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/

#11


0  

I was having the same issue but it turned out that I was specifying the wrong port on localhost. When the dev server(s) start up the log specifies three discreet ports on localhost:

我遇到了同样的问题,但结果是我在本地主机上指定了错误的端口。当dev服务器启动日志时,在本地主机上指定三个谨慎的端口:

INFO 2015-07-26 03:46:56,023 api_server.py:172] Starting API server at: http:// localhost:35714

信息2015-07-26 03:46:56,023 api_server。py:172]启动API服务器:http:// localhost:35714。

INFO 2015-07-26 03:46:56,027 dispatcher.py:186] Starting module "default" running at: http:// localhost:8080

信息2015-07-26 03:46:56,027调度员。py:186]启动模块“默认”运行:http:// localhost:8080。

INFO 2015-07-26 03:46:56,028 admin_server.py:118] Starting admin server at: http:// localhost:8000

信息2015-07-26 03:46:56,028 admin_server。py:118]启动管理服务器:http:// localhost:8000。

The issue was that I was trying to use the port for the api server but you need to just use the port for the default module.

问题是,我试图使用端口作为api服务器,但您只需要为默认模块使用端口。

This works: http:// localhost:8080/_ah/api/explorer (I needed to click the shield in chrome and allow unsafe scripts because the url is unencrypted)

它的工作是:http:// localhost:8080/_ah/api/explorer(我需要在chrome中点击屏蔽,允许不安全的脚本,因为url是未加密的)

#1


4  

The URL for the API Explorer is correct, but there have been some issues (apparently not all resolved) where the API Explorer doesn't correctly list your APIs.

API资源管理器的URL是正确的,但是有一些问题(显然不是全部解决),API资源管理器没有正确地列出您的API。

As comparison of how it should look like https://developers.google.com/apis-explorer/ is the API Explorer for Google APIs, far more APIs than you would normally host yourself, but just to give you an idea of what you should see: a list of APIs and details for each API once you click on it.

如何应该类似于https://developers.google.com/apis-explorer/的比较是Google的API浏览器API,API远比你通常会主持人自己,只是给你一个想法,你应该看到:为每个API列表API和细节一旦你点击它。

A workaround that usually worked is to explicitly add the name and version of your API to the URL, so since your API is called scrnxSync with version v1 this link should show you the methods you defined for your API, and allow you to call those methods:

通常工作的一种方法是显式地将API的名称和版本添加到URL中,因此,由于您的API被称为“scrnxSync”,而vv1这个链接应该向您显示您为API定义的方法,并允许您调用这些方法:

https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/scrnxSync/v1/

https://developers.google.com/apis-explorer/?base=http:/ / localhost:8080 / # p / scrnxSync _ah / api / v1 /

#2


8  

Something changed, and now you must start Chrome in a specific way to use api explorer on localhost development server

有些事情发生了变化,现在您必须以一种特定的方式启动Chrome,以在本地主机开发服务器上使用api explorer。

here is a link to info from google.

这里是一个从谷歌的信息链接。

But for me it still didn't fix using api explorer with localhost dev server.
I find that a possible workaround is to launch Chrome with the flag "--allow-running-insecure-content"
On MacOs in terminal run this:

但对我来说,它仍然没有使用localhost开发服务器来修复api资源管理器。我发现一个可能的解决方案是在终端运行的MacOs上使用“允许运行不安全”的标志来启动Chrome:

/Applications/Google\ Chrome.app/Contents/Mac/Google\ Chrome --user-data-dir=test --allow-running-insecure-content

/应用程序/谷歌\ Chrome。应用程序/内容/ Mac /谷歌\ Chrome——测试——allow-running-insecure-content user-data-dir =

#3


7  

If you are using Chrome browser, just make https in the URL to http. It worked for me.

如果您使用的是Chrome浏览器,请在URL中使用http。它为我工作。

http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/

http://apis-explorer.appspot.com/apis-explorer/?base=http:/ / localhost:8080 / _ah / api # p /

#4


4  

I tried all of the above in chrome and nothing works for me, but using firefox I just click in the lock at the left of the url bar and disable the security. That made the trick for me, cheers !! :D

我在chrome上尝试了以上所有操作,但没有任何效果,但使用firefox时,我只在url栏左边的锁上单击,然后禁用安全性。这对我来说是一种技巧,干杯!!:D

#5


3  

A quick fix: Open the link: http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/ in firefox , then click the secure connection icon on the nav bar, then click disable protection. You should be able to see your APIs

快速修复:打开链接:http://apis-explorer.appspot.com/apis-explorer/?在firefox中,单击安全连接图标,然后单击禁用保护。您应该能够看到您的api。

ps; Remember to edit 8080 with your port number

ps;记得用您的端口号编辑8080。

#6


2  

I'm also new to GAE Endpoints, and I had the same problem. In my case, I had this error because of the order of the url handlers in the app.yaml. I had it like this:

我对GAE端点也是新的,我也有同样的问题。在我的例子中,我有这个错误,因为app.yaml中url处理程序的顺序。我是这样的:

- url: /.*
  script: core_service.application

  # Endpoints handler
- url: /_ah/spi/.*
  script: api_service.application

The right way is defining first the most specific routes and at the end the most general (/.*). Like this:

正确的方法是先定义最具体的路线,最后确定最一般的路线(/。*)。是这样的:

  # Endpoints handler
- url: /_ah/spi/.*
  script: api_service.application

- url: /.*
  script: core_service.application

#7


2  

I know it is not exactly the same problem but I was having the message "You are exploring an API that is described or served via HTTP instead of HTTPS. This is insecure and may be blocked by your browser. To fix this, set up a TLS proxy for your API. Alternatively, you can tell your browser to allow active content via HTTP at this site (on Chrome, click the shield in the URL bar), but this will not improve security or dismiss this message."

我知道这并不是完全相同的问题,但我有一个消息:“您正在探索一个通过HTTP而不是HTTPS来描述或服务的API”。这是不安全的,可能会被浏览器阻塞。要修复这个问题,请为您的API设置一个TLS代理。或者,你可以告诉你的浏览器允许在这个站点上通过HTTP进行活动内容(在Chrome上,点击URL栏中的屏蔽),但是这不会提高安全性或者忽略这个消息。

Clicking the shield icon in the address bar of Chrome did it for me.

在Chrome的地址栏中点击“屏蔽”图标就可以了。

#8


1  

If you are running the AppEngine from GWT DevMode you need to change port in the base parameter to match what you see in console, for me that's 8888:

如果您从GWT DevMode运行AppEngine,您需要在基本参数中更改端口,以匹配您在控制台上看到的内容,对我来说是8888:

http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8888/_ah/api#p/

http://apis-explorer.appspot.com/apis-explorer/?base=http:/ / localhost:8888 / _ah / api # p /

#9


0  

For me, it is a very simple typo in app.yaml. If you have the same problem, it can be just this simple:

对我来说,这是一个非常简单的错误。如果你有同样的问题,可以这么简单:

Instead of (which is correct):

而不是(这是正确的):

- url: /_ah/spi/.*
  script: services.application

I put:

我把:

- url: /_ah/api/.*
  script: services.application

Changing api back to spi did the trick.

改变api回到spi做了这个魔术。

#10


0  

The problem is that your python file can't find the import for:

问题是您的python文件无法找到:

from protorpc import remote

Therefore use the terminal, skip the GUI, navigate to the appengine sdk directory and put your project in there. For mac it is:

因此,使用终端,跳过GUI,导航到appengine sdk目录,并将您的项目放入其中。对于mac:

/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/

#11


0  

I was having the same issue but it turned out that I was specifying the wrong port on localhost. When the dev server(s) start up the log specifies three discreet ports on localhost:

我遇到了同样的问题,但结果是我在本地主机上指定了错误的端口。当dev服务器启动日志时,在本地主机上指定三个谨慎的端口:

INFO 2015-07-26 03:46:56,023 api_server.py:172] Starting API server at: http:// localhost:35714

信息2015-07-26 03:46:56,023 api_server。py:172]启动API服务器:http:// localhost:35714。

INFO 2015-07-26 03:46:56,027 dispatcher.py:186] Starting module "default" running at: http:// localhost:8080

信息2015-07-26 03:46:56,027调度员。py:186]启动模块“默认”运行:http:// localhost:8080。

INFO 2015-07-26 03:46:56,028 admin_server.py:118] Starting admin server at: http:// localhost:8000

信息2015-07-26 03:46:56,028 admin_server。py:118]启动管理服务器:http:// localhost:8000。

The issue was that I was trying to use the port for the api server but you need to just use the port for the default module.

问题是,我试图使用端口作为api服务器,但您只需要为默认模块使用端口。

This works: http:// localhost:8080/_ah/api/explorer (I needed to click the shield in chrome and allow unsafe scripts because the url is unencrypted)

它的工作是:http:// localhost:8080/_ah/api/explorer(我需要在chrome中点击屏蔽,允许不安全的脚本,因为url是未加密的)