#socialite microsoft oauth2 / check user in db / login => session pb

5 messages · Page 1 of 1 (latest)

dusky glen
#

Hi.
I am using socialite to connect my localhost website to microsoft oauth2. Everything goes well on the authorize. The callback is also good. My user is retrieved. I check the user in my own database. Perfect.
I save all these information (access token, refresh token, expires...) in session. At the end of this last page, before redirecting to homepage, I check the session variables, they are here.
Then, problems are coming ! On the homepage, everything is lost. Go back to login. No more session variables.
I see that sessionids are different on these two pages (callback and home). I have read a lot of stuff (3 days). And I have tried many solutions, in vain. What I understood is that : as the site is leaving the website to microsoft (socialite), it looses sesion.
By the way, I am on http://localhost and microsoft is on https. Maybe a tip... But I can't put localhost on https.
I am desesperate...
Thanks by advance.
Jerome

#

I have tagged "passport" because I am not sure if it could help bu installing this kit. Maybe I could save the user in database on the callback url... But as I loose the tokens sessions when going to the homepage, how can I retrieve the user then...?

sweet holly
#

You can use a tool like ngrok to make a local site available on the internet via https. That's usually what I do when developing oauth callbacks.

#

You could also try changing the session config value for same_site. Can't remember which value to use. It's either "none" or "lax". And remember to clear your cookies after changing the config.

dusky glen
#

Hi, thanks for your answer. I finally found the solution. I was making some var_dump and dd() before redirecting. I don't know why, it was breaking my session and without all debugging stuff, everything works like a charm.