简体   繁体   English

Authenticator和PeerAuthenticator无法使用Appengine端点

[英]Authenticator and PeerAuthenticator Not working Appengine endpoints

After upgrading to V2 Endpoints my API's that used @peerAuthenticator failed to validate the peer. 升级到V2端点后,使用@peerAuthenticator的我的API无法验证对等端。 I did the tests with the @Authenticator and had the same problem, ignored the execution. 我使用@Authenticator进行了测试,但遇到了同样的问题,忽略了执行。

I've created a repository on GitHub to test with an empty application. 我已经在GitHub上创建了一个存储库以测试一个空的应用程序。

The repository was created through the steps of google documentation . 该存储库是通过Google文档的步骤创建的。

  • After running the app mvn appengine:run you can request to 3 endpoints: 在运行应用程序mvn appengine:run您可以请求3个端点:

  • API 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. 您没有在@Api@ApiMethod批注中设置身份验证者或对等身份验证者。 See the Javadoc . 参见Javadoc

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

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