Fork me on GitHub
#ring
<
2024-05-15
>
DerTev19:05:05

When trying to authenticate with Spotify using https://github.com/weavejester/ring-oauth2, I keep getting a State mismatch -Error although the state-query-parameter seems to match. The url I get redirected to the auth server is and the url I get redirected to my ring server is http://.../.../callback?code=...&state=UL4bxxxTXwcB.

hiredman19:05:28

Are you using the session middleware?

hiredman19:05:42

What routing library are you using?

DerTev19:05:07

> Are you using the session middleware? I dont think so, do I need that middleware? > What routing library are you using? I use reitit.

hiredman19:05:21

reitit has some gotchas with session middleware you may need to be aware of

hiredman19:05:55

I am not sure, but the code looks like it expects to use sessions

DerTev19:05:23

So this library is not really usable with reitit?

hiredman19:05:29

The state check checks that the state in the url matches what is stored in the session

hiredman19:05:59

I think it should be

DerTev19:05:30

So what should I do now to fix the issue?

hiredman19:05:23

It may not even hit the gotchas that wrap-session has with reitit, those are if you try to share a session between routes, and there are several work around s, so not a huge problem just easy to get stuck on if you are not aware

hiredman19:05:38

I would try adding wrap-session

DerTev19:05:56

In which namespace is wrap-session ?

hiredman19:05:40

Dunno offhand it is part of the standardish ring middleware

hiredman19:05:33

https://github.com/metosin/reitit/issues/205#issue-399958744 talks about the issues with wrap-session and reitit and describes several solutions to making them work together

hiredman19:05:59

ring.middleware.session I guess

weavejester20:05:17

If you use a non-memory session store, wrap-session should work fine with Reitit. Ring-Defaults will automatically add an encrypted cookie session store, for example.

DerTev20:05:40

wrap-session fixed the issue, thanks a lot!