在python标准环境快速入门中,端点方法test_api_key返回503服务不可用。在使用dev_appser.py运行时以及部署API时,API Explorer中会发生错误。它的代码是:Google Cloud Endpoints Python快速入门回声示例问题
import endpoints
from protorpc import message_types
from protorpc import messages
from protorpc import remote
class TestResponse(messages.Message):
content = messages.StringField(1)
@endpoints.api(name='practice', version='v1', description='My Practice API')
class PracticeApi(remote.Service):
@endpoints.method(
message_types.VoidMessage,
TestResponse,
path='test/getApiKey',
http_method='GET',
name='test_api_key')
def test_api_key(self, request):
return TestResponse(content=request.get_unrecognized_field_info('key'))
api = endpoints.api_server([PracticeApi])
我没有.get_unrecognized_field_info(“键”)有很好的理解,所以我不知道是什么问题?谢谢。
在文件(openapi.json)中的哪个位置放置了api密钥?谢谢 –
正如我限制所有的方法,我会在[本文档](https://cloud.google.com/endpoints/docs/restricting-api-access-with-api-keys-openapi)中添加。把它放在文件的顶层,而不是嵌套在方法info中。 – Nicholas