繁体   English   中英

Authenticator和PeerAuthenticator无法使用Appengine端点

[英]Authenticator and PeerAuthenticator Not working Appengine endpoints

升级到V2端点后,使用@peerAuthenticator的我的API无法验证对等端。 我使用@Authenticator进行了测试,但遇到了同样的问题,忽略了执行。

我已经在GitHub上创建了一个存储库以测试一个空的应用程序。

该存储库是通过Google文档的步骤创建的。

  • 在运行应用程序mvn appengine:run您可以请求3个端点:

  • 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"); } } 
  • 同行认证者

     public class PeerAuthenticator implements com.google.api.server.spi.config.PeerAuthenticator{ @Override public boolean authenticate(HttpServletRequest arg0) { // TODO Auto-generated method stub return true; } } 

有人遇到过同样的问题吗? 有什么解决办法吗?

您没有在@Api@ApiMethod批注中设置身份验证者或对等身份验证者。 参见Javadoc

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM