Hi have a service developed using Akka-Http. I have to add OAuth to it and according to the documentation, I am using authenticateOAuth2
for this.
However the code isn't compiling and gives the error as
Type mismatch, expected: (L) => server.Route, actual: (OauthInfo) => server.Route
I am unable to find a proper solution to fix this issue. I even tried the exact code mentioned in the example in the documentation but it still throws similar compile time error.
I am using akka-http with circle.
Here is my code:
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
}
}
This was an error in IntelliJ.
The code runs fine but due to some reason IntelliJ Idea shows error all over it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With