So I am running the sample code provided by Google:
package com.neat.backend;
/**
* An endpoint class we are exposing
*/
@Api(
name = \"myApi\",
It took me a while and a bit of debugging to realize that the filter that is supposed to inject method_info was not being fired.
I could fix it by modifying the mapping in web.xml adding the following dispatcher tags:
<filter-mapping>
<filter-name>endpoints-api-configuration</filter-name>
<servlet-name>EndpointsServlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
I got the same error message, and eventually tracked it down to making a request with a trailing /
in the URL where my API did not specify one. The trailing slash only causes an error for calls that provide an authorization token.
Apparently ControlFilter
(and therefore also GoogleAppEngineControlFilter
) did not recognize it as a valid endpoint and therefore did not bother attaching method_info
to the request. But then EndpointsServlet
thought it was valid and tried to authenticate without all the needed info!
The fix was easy: remove the trailing slash from the URL in my request. Tracking down the problem, however, was not! I see this was not your problem, but maybe this answer will help someone else.
@Kevendra's answer highlights that this issue can be caused if an openapi.json
file is missing a reference to the endpoint API method. Firebase may be using this to reference and discover the API method.
From the Google OpenAPI Overview:
Basic structure of an OpenAPI document:
An OpenAPI document describes the surface of your REST API, and defines information such as:
The name and description of the API. The individual endpoints (paths) in the API. How the callers are authenticated.
Follow these steps to regenerate and deploy the openapi.json file:
generate:
$ mvn clean package endpoints-framework:openApiDocs -DskipTests
mvn clean
- run a Maven goal to clean your project. package
- compile and package itopenapi.json
file at the location: target/openapi-docs/openapi.json
- see generating and deploying an api configuration.-DskipTests
skips running any tests, to avoid any test failure due
to the openapi.json not yet being generateddeploy:
(As a precaution you can first validate the project ID returned from the following command to make sure that the service isn't created in the wrong project - gcloud config list project
)
$ gcloud endpoints services deploy target/openapi-docs/openapi.json
Deploys the openapi.json file from its generated location (in the 'generate' step above). See the Google docs on Deploying the OpenAPI document
generat and deploy the OpenAPI configuration file
$ mvn clean package endpoints-framework:openApiDocs -DskipTests
$ gcloud endpoints services deploy target/openapi-docs/openapi.json
$ mvn appengine:run