簡體   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