![]() You might want to do this, for example, when you have multiple points of login, and you need to know (at the destination) where the user came from. Overall, this works very well, except when you need to pass some custom data to the destination URI on-the-fly. Note: On step 2, when jumping to Google, Socialite appends a special query parameter called redirect_uri, which is your app’s URI where Google will redirect the user at step 4. ![]() AuthController::callbackFromGoogle() įinally your app extracts the user’s data (returned by Google) using Socialite::driver('google')->user() and proceeds to authenticate current session (btw, the user is created if new). Then, Google redirects the user back to your application’s callback route, e.g. Your app redirects using Socialite::driver('google')->redirect() which redirects the user to Google’s authentication page The user clicks “Sign in with Google” which calls a method in your app’s authentication controller, for example AuthController::signInWithGoogle() Just as a brief clarification, the Socialite/OAuth flow implies the following steps (note that I’m using Google here as an example, but it can be any OAuth service provider): Passing dynamic data to the external OAuth system and getting that data back to your application, using Socialite, is something neither easily done nor well documented and given that I’ve seen a lot of people wasting time on this, I want to try and shed some light on it here. If you’ve ever done authentication in a Laravel-based project then you probably had to deal with the Socialite extension, which enables OAuth-based authentication using third-party services (like Google or Facebook). ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |