Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bbdev's avatar
Level 1

How to get Passport access/refresh tokens for my API after socialite login

I'm having difficulties combining Laravel passport with Laravel Socialite. I have an API with OAuth2 implementation using passport. The API is used by a SPA (Nuxt). The SPA uses the password grant flow for 'regular' login using an email and password. The SPA also provides the options to login through Google or Facebook. Socialite handles the login flow with google/facebook but I don't know how to get access/refresh tokens for my API after the socialite flow.

I can't use the password grant since this requires a password. Which grant could/should I use and for what reason? Also how do I get the access/refresh token from my API to my SPA in the google/facebook callback? SPA -> API communication is straight forward but two way communication would require event broadcasting (WebSockets) or some sort of solution.

For clarification:

Single sign on flow:

  • In the SPA login view open google/facebook login through button
  • Login on google/facebook
  • Redirects to API on success
  • Handle callback (get access/refresh tokens and send these to SPA).
0 likes
0 replies

Please or to participate in this conversation.