diff --git a/appengine/endpoints-frameworks-v2/backend/README.md b/appengine/endpoints-frameworks-v2/backend/README.md index 18322cab66e..d7b23ec6bdd 100644 --- a/appengine/endpoints-frameworks-v2/backend/README.md +++ b/appengine/endpoints-frameworks-v2/backend/README.md @@ -27,16 +27,7 @@ To build the project: To generate the required configuration file `swagger.json`: -0. Download and unzip the [Endpoints Framework tools -package](http://search.maven.org/remotecontent?filepath=com/google/endpoints/endpoints-framework-tools/2.0.0-beta.7/endpoints-framework-tools-2.0.0-beta.7.zip). - -0. Invoke the Endpoints Tool using this command: - - path/to/endpoints-framework-tools-2.0.0-beta.7/bin/endpoints-framework-tools get-swagger-doc \ - -h .appspot.com \ - -w target/echo-1.0-SNAPSHOT com.example.echo.Echo - - Replace`` with your project ID. + mvn exec:java -DGetSwaggerDoc ## Deploying the sample API to App Engine diff --git a/appengine/endpoints-frameworks-v2/backend/pom.xml b/appengine/endpoints-frameworks-v2/backend/pom.xml index 3c4796f3294..a0cabc5964b 100644 --- a/appengine/endpoints-frameworks-v2/backend/pom.xml +++ b/appengine/endpoints-frameworks-v2/backend/pom.xml @@ -31,6 +31,9 @@ UTF-8 + 2.0.0-beta.7 + 1.0.0-beta.7 + YOUR_PROJECT_ID @@ -45,10 +48,62 @@ com.google.endpoints endpoints-framework - 2.0.0-beta.7 + ${endpoints.framework.version} + + + com.google.endpoints + endpoints-management-control-appengine + ${endpoints.management.version} + + + com.google.endpoints + endpoints-framework-auth + ${endpoints.management.version} + + + GetSwaggerDoc + + + GetSwaggerDoc + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.4.0 + + true + com.google.api.server.spi.tools.EndpointsTool + + get-swagger-doc + --hostname=${endpoints.project.id}.appspot.com + --war=target/echo-1.0-SNAPSHOT + com.example.echo.Echo + + + + + com.google.endpoints + endpoints-framework-tools + ${endpoints.framework.version} + + + com.google.appengine + appengine-api-1.0-sdk + 1.9.30 + + + + + + + + ${project.build.directory}/${project.build.finalName}/WEB-INF/classes diff --git a/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java b/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java index 8a7d050051a..f8bc0590748 100644 --- a/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java +++ b/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java @@ -16,10 +16,12 @@ package com.example.echo; +import com.google.api.server.spi.auth.EspAuthenticator; import com.google.api.server.spi.auth.common.User; import com.google.api.server.spi.config.Api; import com.google.api.server.spi.config.ApiMethod; import com.google.api.server.spi.config.ApiNamespace; +import com.google.api.server.spi.config.AuthLevel; /** The Echo API which Endpoints will be exposing. */ @Api( @@ -57,7 +59,12 @@ public Message echo(Message message) { * Note that httpMethod is not required here. Without httpMethod, this will default to GET due * to the API method name. httpMethod is added here for example purposes. */ - @ApiMethod(httpMethod = ApiMethod.HttpMethod.GET) + @ApiMethod( + httpMethod = ApiMethod.HttpMethod.GET, + authenticators = {EspAuthenticator.class}, + audiences = {"YOUR_OAUTH_CLIENT_ID"}, + authLevel = AuthLevel.REQUIRED + ) public Email getUserEmail(User user) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException(); diff --git a/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml index 274894e136b..8f249f751a1 100644 --- a/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml +++ b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml @@ -26,4 +26,8 @@ + + + + diff --git a/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml index 53beffe8208..66db1fda503 100644 --- a/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml +++ b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml @@ -32,4 +32,34 @@ index.html + + + + endpoints-api-configuration + com.google.api.control.ServiceManagementConfigFilter + + + + + endpoints-api-controller + com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter + + endpoints.projectId + ${endpoints.project.id} + + + endpoints.serviceName + ${endpoints.project.id}.appspot.com + + + + + endpoints-api-configuration + EndpointsServlet + + + + endpoints-api-controller + EndpointsServlet +