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.
How to use socialite for api for login.
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 ?
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.