phplaravelauthenticationsocial-media

Get social user info in view Laravel


I am using laravel social auth guide and I dont know how can I get users info from database. To get info by auth user I can use Auth::user()->id; to get info by users created by normal register. How get id of user logged by socialmedia?


Solution

  • If you are using Socialite class and facebook service provider:

    $user = Socialite::driver('facebook')->user();
    

    Once, you get the user instance, you can get few more details with:

    $user->name;
    $user->email;
    

    See Social authentication using Socialite for more.