1

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?

blackgreen
  • 34,072
  • 23
  • 111
  • 129
MaoStream
  • 188
  • 9
  • There is a part about [social authentication](https://laravel.com/docs/5.0/authentication#social-authentication) in the docs. – Phiter Oct 25 '16 at 17:56
  • For Facebook, I keep the user's ID in the database and I keep their authentication token in there with it for the duration of their login. Then use the two to make API calls. I'm sure there's a better way to do that, but it's how I do it – Pazuzu156 Oct 25 '16 at 17:58

1 Answers1

1

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.

Sanzeeb Aryal
  • 4,358
  • 3
  • 20
  • 43