Laravel Socialite, Login with Google in mobile App - userFromToken

93 Views Asked by At

I am trying to implement Laravel social login with google (API for mobile APP), but I am stuck with scopes. No matter how I try, I cannot access the gender and date of birth.

I am creating access_token here: https://developers.google.com/oauthplayground

with selected and authorised API's:

email, profile, https://www.googleapis.com/auth/user.gender.read, https://www.googleapis.com/auth/user.birthday.read

and then in Laravel trying to get user data. Here is my code:

$scopes = [
            'https://www.googleapis.com/auth/user.birthday.read',
            'https://www.googleapis.com/auth/userinfo.email',
            'https://www.googleapis.com/auth/userinfo.profile',
            'https://www.googleapis.com/auth/user.gender.read',
        ];

        $provider_user = Socialite::driver($sanitizedData['provider'])
            ->scopes($scopes)->userFromToken($sanitizedData['token']);

I receive id, name, email, avatar, nickname etc... but no gender and birthdate

0

There are 0 best solutions below