cloudendpoints / endpoints-python

A Python framework for building RESTful APIs on Google App Engine
Apache License 2.0
51 stars 17 forks source link

when endpointscfg, got "TypeError: Missing issuer google_id_token" #174

Closed simpledong81 closed 5 years ago

simpledong81 commented 6 years ago

I used "python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo" for example. When I follow the Google document "https://cloud.google.com/endpoints/docs/frameworks/python/authenticating-users" and add Firebase User Authentication to the endpoints.api decorator, I cannot generate the openapi document. Is there anything that I have missed?

The source code is

@endpoints.api(
    name='echo',
    version='v1',
    issuers={'firebase': endpoints.Issuer(
        'https://securetoken.google.com/wang-project-xxxxx',
        'https://www.googleapis.com/service_accounts/v1/metadata/x509/securetoken@system.gserviceaccount.com')})
class EchoApi(remote.Service):

And the error is

python lib/endpoints/endpointscfg.py get_openapi_spec main.EchoApi --hostname wang-project-xxxxx.appspot.com
Traceback (most recent call last):
  File "lib/endpoints/endpointscfg.py", line 31, in <module>
    main(sys.argv)
  File "/Users/somebody/works/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/_endpointscfg_impl.py", line 617, in main
    args.callback(args)
  File "/Users/somebody/works/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/_endpointscfg_impl.py", line 465, in _GenOpenApiSpecCallback
    x_google_api_name=args.x_google_api_name)
  File "/Users/somebody/works/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/_endpointscfg_impl.py", line 308, in _GenOpenApiSpec
    x_google_api_name=x_google_api_name)
  File "/Users/somebody/works/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/_endpointscfg_impl.py", line 216, in GenApiConfig
    services, hostname=hostname, **additional_kwargs))
  File "/Users/somebody/works/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/openapi_generator.py", line 1043, in pretty_print_config_to_json
    descriptor = self.get_openapi_dict(services, hostname, x_google_api_name=x_google_api_name)
  File "/Users/somebody/works/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/openapi_generator.py", line 1029, in get_openapi_dict
    return self.__api_openapi_descriptor(services, hostname=hostname, x_google_api_name=x_google_api_name)
  File "/Users/somebody/works/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/openapi_generator.py", line 930, in __api_openapi_descriptor
    security_definitions)
  File "/Users/somebody/works/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/openapi_generator.py", line 750, in __method_descriptor
    api_key_required=api_key_required)
  File "/Users/somebody/works/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/openapi_generator.py", line 779, in __security_descriptor
    raise TypeError('Missing issuer {}'.format(issuer))
TypeError: Missing issuer google_id_token
inklesspen commented 5 years ago

Can you describe how you're setting audiences in your api?