升级到V2端点后,使用@peerAuthenticator的API无法验证对等端。我使用@Authenticator进行了测试并遇到了同样的问题,忽略了执行。
我创建了一个repository on GitHub来测试一个空的应用程序。
存储库是通过google documentation。
的步骤创建的运行应用mvn appengine:run
后,您可以请求3个端点:
@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();
}
}
身份验证
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;
}
}
有没有人有同样的问题?任何解决方案?