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..ac799f82599 100644 --- a/appengine/endpoints-frameworks-v2/backend/pom.xml +++ b/appengine/endpoints-frameworks-v2/backend/pom.xml @@ -31,9 +31,21 @@ UTF-8 + 2.0.0-beta.7 + 0.0.20-SNAPSHOT + YOUR_PROJECT_ID + + + + internal-endpoints-testing + Internal Endpoints Testing + http://104.197.230.53:8081/nexus/content/repositories/snapshots/ + + + @@ -45,10 +57,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..977f5b94c65 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 @@ + + + +