python標準環境のクイックスタートでは、エンドポイントメソッドのtest_api_keyが503 Service Unavailableを返します。このエラーは、dev_appser.pyで実行したときとAPIをデプロイしたときにAPIエクスプローラで発生します。そのためのコードは次のとおりです。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)のようにすべてのメソッドを追加していたので、制限していました。それをファイルの最上位レベルに置き、メソッド情報に入れ子にしないでください。 – Nicholas