None of the registered handlers can handle the given state item


#1

Hello,

I am trying to pass UserStateItem parameter to the authenticate method of OAuth2Provider as described in the example:

def authenticate(provider: String) = Action.async { implicit request: Request[AnyContent] =>
  (socialProviderRegistry.get[SocialProvider](provider) match {
    case Some(p: OAuth2Provider with CommonSocialProfileBuilder) =>
      p.authenticate(UserStateItem(Map("url" -> "https://silhouette.rocks"))).flatMap {
        case Left(result) => Future.successful(result)
        case Right(StatefulAuthInfo(authInfo, userState)) => ...

The provider authenticates successfully, but the Right() statement results in the ProviderException:

None of the registered handlers can handle the given state item:
ItemStructure(csrf-state,{"token":"4399ca81cc550cf9976..."})

The debugger shows that both CsrfStateItemHandler and UserStateItemHandler are registered. What can possibly be missing? The CSRF state item handler settings are:

csrfStateItemHandler.cookieName="OAuth2State"
csrfStateItemHandler.cookiePath="/"
csrfStateItemHandler.secureCookie=false
csrfStateItemHandler.httpOnlyCookie=true
csrfStateItemHandler.expirationTime=5 minutes
csrfStateItemHandler.signer.key = "[changeme]"

(I tried to use csrfStateItemHandler.cookieName="token" but it did not solve the problem).

(Using Scala 2.12.4, Play 2.6.11, Silhouette 5.0.0)

Thank you in advance!

Roni.


#2

There was an issue in version 5.0.0. Have you tried the newest version (5.0.4)?


#3

Thank you so much, @akkie! I upgraded to 5.0.4 and everything worked!!!