After upgrading to V2 Endpoints my API's that used @peerAuthenticator failed to validate the peer. I did the tests with the @Authenticator and had the same problem, ignored the execution.
I've created a repository on GitHub to test with an empty application.
The repository was created through the steps of google documentation .
After running the app mvn appengine:run
you can request to 3 endpoints:
@authenticator
) @peerAuthenticator
) API
@Api(name = "myapi", version = "v1") public class YourFirstAPI { @ApiMethod(name = "firstApiMethod", path = "firstApiMethod", httpMethod = HttpMethod.GET) public TestObject a() { return new TestObject(); } @ApiMethod(name = "b", path = "b", httpMethod = HttpMethod.GET, authenticators = {Authenticator.class}) public TestObject b() { return new TestObject(); } @ApiMethod(name = "c", path = "c", httpMethod = HttpMethod.GET, peerAuthenticators = PeerAuthenticator.class) public TestObject c() { return new TestObject(); } }
Authenticator
public class Authenticator implements com.google.api.server.spi.config.Authenticator { @Override public User authenticate(HttpServletRequest arg0) throws ServiceException { throw new ServiceException(401, "unauthorized"); } }
PeerAuthenticator
public class PeerAuthenticator implements com.google.api.server.spi.config.PeerAuthenticator{ @Override public boolean authenticate(HttpServletRequest arg0) { // TODO Auto-generated method stub return true; } }
Has anyone had the same problem? Any Solution for this?
You did not set your authenticator or peer authenticator in your @Api
or @ApiMethod
annotation. See the Javadoc .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.