I follow this article in login with Google . I can redirect to gmail login successfully. In addition, it successfully returns to the callback URL.
Below is my code
public function showGoogleLoginForm() { $providerKey = \Config::get('services.google'); return \Socialite::driver( 'google' )->scopes(['profile', 'email'])->redirect(); }
Problem
Now I'm trying to check if the callback gives me the email address of the user or not. Thus, I could verify that the user is registered in my database or not.
Is there a way to get the email address in the callback?
I can redirect the user to the gmail login, and also I can reach my callback method. In the callback method, I got an error in this code: \Socialite::driver( 'google' )->user()
I got this Error when I used this code \Socialite::driver( 'google' )->user();
source share