SocialStateProvider ProviderException: None of the registered handlers can handle the given state item

Hi,

I’m having the following issue with the SocialStateProvider while attempting to authenticate the first time using Facebook. The first time this error comes up, the second time it goes through and authenticates correctly. Can anyone point me where to look or whether this is a known configuration issue? I’d like to skip hours of Debugging if possible :smile:

Here is the output I’m getting the first time attempting to relogin to Facebook, the second time I click the Facebook link it works:

[warn] c.m.p.s.i.p.s.CsrfStateItemHandler - [Silhouette][CsrfStateItemHandler] State cookie doesn't exists for name: OAuth2State
com.mohiva.play.silhouette.impl.exceptions.OAuth2StateException: [Silhouette][CsrfStateItemHandler] State cookie doesn't exists for name: OAuth2State
	at com.mohiva.play.silhouette.impl.providers.state.CsrfStateItemHandler.clientState(CsrfStateItemHandler.scala:175)
	at com.mohiva.play.silhouette.impl.providers.state.CsrfStateItemHandler.canHandle(CsrfStateItemHandler.scala:110)
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$3(SocialStateProvider.scala:289)
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$3$adapted(SocialStateProvider.scala:289)
	at scala.collection.immutable.Set$Set1.find(Set.scala:106)
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$2(SocialStateProvider.scala:289)
	at scala.collection.immutable.List.map(List.scala:286)
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$1(SocialStateProvider.scala:288)
	at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
	at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
[warn] c.z.h.p.HikariPool - db - Thread starvation or clock leap detected (housekeeper delta=2m59s591ms315µs206ns).
[error] c.SocialAuthController - Unexpected provider error
com.mohiva.play.silhouette.api.exceptions.ProviderException: None of the registered handlers can handle the given state item: ItemStructure(csrf-state,{"token":"5148183055973bd54771ee2e9cfb729fa9a3eaec3554364071dfa165228e2f5c28b121dc877155f21740c7fb44ed57526d9fbc0e5c47e5c14ab033a55310773d73047cb4494c088e80032af62bffebe709fcb3a807d589081d75a1b5c889dfe88c710145f3b866ecd5a02e81de2bfcc537791ec477e6b8e16b36df9559de54b3"})
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$2(SocialStateProvider.scala:291)
	at scala.collection.immutable.List.map(List.scala:286)
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$1(SocialStateProvider.scala:288)
	at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
	at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
	at scala.concurrent.impl.CallbackRunnable.run$$$capture(Promise.scala:64)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
[warn] c.m.p.s.i.p.s.CsrfStateItemHandler - [Silhouette][CsrfStateItemHandler] State cookie doesn't exists for name: OAuth2State
com.mohiva.play.silhouette.impl.exceptions.OAuth2StateException: [Silhouette][CsrfStateItemHandler] State cookie doesn't exists for name: OAuth2State
	at com.mohiva.play.silhouette.impl.providers.state.CsrfStateItemHandler.clientState(CsrfStateItemHandler.scala:175)
	at com.mohiva.play.silhouette.impl.providers.state.CsrfStateItemHandler.canHandle(CsrfStateItemHandler.scala:110)
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$3(SocialStateProvider.scala:289)
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$3$adapted(SocialStateProvider.scala:289)
	at scala.collection.immutable.Set$Set1.find(Set.scala:106)
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$2(SocialStateProvider.scala:289)
	at scala.collection.immutable.List.map(List.scala:286)
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$1(SocialStateProvider.scala:288)
	at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
	at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
[error] c.SocialAuthController - Unexpected provider error
com.mohiva.play.silhouette.api.exceptions.ProviderException: None of the registered handlers can handle the given state item: ItemStructure(csrf-state,{"token":"5148183055973bd54771ee2e9cfb729fa9a3eaec3554364071dfa165228e2f5c28b121dc877155f21740c7fb44ed57526d9fbc0e5c47e5c14ab033a55310773d73047cb4494c088e80032af62bffebe709fcb3a807d589081d75a1b5c889dfe88c710145f3b866ecd5a02e81de2bfcc537791ec477e6b8e16b36df9559de54b3"})
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$2(SocialStateProvider.scala:291)
	at scala.collection.immutable.List.map(List.scala:286)
	at com.mohiva.play.silhouette.impl.providers.DefaultSocialStateHandler.$anonfun$unserialize$1(SocialStateProvider.scala:288)
	at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
	at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
	at scala.concurrent.impl.CallbackRunnable.run$$$capture(Promise.scala:64)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)

The project is available at:

What’s different is that it employes MySQL and Slick as DAO backend.

Many TIA,
Best regards,
Giovanni

Maybe this?

Hi Christian! thanks! I saw it but doesn’t help.

To be precise, this happens for me using Chrome (need to test with Firefox too) under these two scenarios:

  1. The user signs out and signs in again
  2. The user closes and reopens the browser.

Case #1 is fixed by commenting out the two following settings in silhouette.conf:

  #authenticator.sameSite="Lax"
  #csrfStateItemHandler.sameSite="Lax"

Case #2 doesn’t work no matter what I change.