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

princeoo7's avatar

Need Help in figuring out how to work with laravel socialite api and flutter app

Hello Everyone!

I was thinking about how socialite works and then was thinking to create a test project to make a flutter app login with the ability to login with socila media account. Gmail at the moment. How issue is as below.

  1. How to use socialite for api for login.
  2. How to use this in flutter app.

What I have seen is, if using flutter app, we can directly connect to gmail in the same way that laravel does. but then how to maintain session on laravel ? also how to get the data for laravel account if the user is new user ?

0 likes
4 replies
bobbybouwmann's avatar

You can't use a session since you're using an API from your app. Because of this everything is stateless.

In general, you have a flow like this

  • User opens flutter app
  • User logs in using Gmail
  • App sends the user to Gmail for confirmation (using socialite). This is probably an in-app browser
  • User log in at Gmail
  • User is sent back to the page of your backend with some access token
  • Backend saves access token
  • Backend let the app know that the user is logged in and sends the API token to the app (this can be done using a WebSocket or maybe you can communicate to the app, not sure if that is possible)
  • User closes the in-app browser
  • User is logged in

For the API authentication, it would be good to use Laravel Passport or Laravel Airlock.

1 like
princeoo7's avatar

yes I am stuck with the issue of invalid_credential :(

Please or to participate in this conversation.