2017-10-19 118 views
3

您好有使用Akka-Http開發的服務。我必須添加OAuth並根據documentation,我正在使用authenticateOAuth2無法使用Akka-Http驗證OAuth2

然而代碼不編譯和給出誤差作爲

類型不匹配,預期:(​​L)=> server.Route,實際:(OauthInfo)=> server.Route

我無法找到解決此問題的適當解決方案。我甚至在文檔中嘗試了example中提到的確切代碼,但它仍然會引發類似的編譯時錯誤。

我正在使用帶圈的akka​​-http。

這裏是我的代碼:

def route(implicit system: ActorSystem, mat: ActorMaterializer): Route = 
Route.seal { 
    pathPrefix("newsletter-preferences") { 
    authenticateOAuth2(realm = "Secure site", authenticator) { authInfo => 
     path("frequency"/LongNumber) { custNum => 
     authorize(hasScopes(authInfo)) { 
      frequencyPreference(custNum) ~ addFreqPref(custNum) 
     } 
     } ~ path("pause"/LongNumber) { custNum => 
     authorize(hasScopes(authInfo)) { 
      pauseInfo(custNum) ~ addPauseInfo(custNum) ~ unPauseUser(custNum) 
     } 
     } 
    } ~ 
     path("health") { 
     healthRoute() 
     } 
    } 
} 

def hasScopes(authInfo: OAuthInfo): Boolean = ??? 

def authenticator(credentials: Credentials)(
    implicit system: ActorSystem, 
    mat: ActorMaterializer): Option[OAuthInfo] = { 
credentials match { 
    case p @ Credentials.Provided(token) => 
    ??? 
    case _ => None 
} 
} 

回答

1

這是的IntelliJ錯誤。
該代碼運行良好,但由於某種原因,IntelliJ Idea顯示錯誤遍佈它。