2017-10-19 187 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显示错误遍布它。