1 month ago

How to combine Socialite + VueJS SPA

Posted 1 month ago by Bartude

Hello fellow developers,

I have a Laravel backend where I want to implement Socialite (mainly for facebook and google, possibly others). And I have a VueJS SPA. I'm not really sure on the best way to make the connection between them both. My main issue I think, lies when the provider goes to the callback. I don't think there is a simple way to then return my generated JWT token back to the SPA. Some possible solutions I've seen/thought of so far, but not sure which one is "better" (subjective of course) are:

  1. At the end of the callback, return to a blade view where there it does a simple postMessage to the SPA to send the JWT token.
  2. Make the callback url go to the SPA, which would then send another request to the backend to either login or register the user, which would return the JWT token.
  3. Just don't install Socialite on the backend and use directly the auth0 library in the SPA.

Anyone have any thoughts on the matter?

Please sign in or create an account to participate in this conversation.