Ad

Retrieve Facebook User Details With Using Socialite Laravel

I am using Laravel version 5.4.36 and I am using Laravel Sociallite plugin to connect users with Facebook.

Now, I want to get Logged in user information like birth date gender, Address, mobile number, or any permissions given in this Facebook official document.

I have tried the following code

$facebookScope = [
        'user_birthday',
        'user_location',
];
$facebookFields = [
        'name', // Default
        'email', // Default
        'gender', // Default
        'birthday', // I've given permission
        'location', // I've given permission
];
return Socialite::driver('facebook')->fields($facebookFields)->scopes($facebookScope)->redirect();

Now when I click on login with the Facebook button it shows error like

Invalid Scopes: user_birthday, user_location. This message is only shown to developers. Users of your app will ignore these permissions if present. Please read the documentation for valid permissions at https://developers.facebook.com/docs/facebook-login/permissions

I have tried different scopes like field name = age and scope = user_age_range field name = birthday and scope name = user_birthday for field name = friends and field name = user_friends

For every scope that I used I get the error of invalid scope. enter image description here

Am I doing something wrong? Do I need to change something in the Facebook application that I have created for login?

Please suggest.

Ad

Answer

Ok, turns out this is related to review after all - if only indirectly.

You now need to have your app in “dev” mode, to be able to ask even people with a role in the app for those permissions.

Once you set it “live”, it will show the “invalid scopes” error, even if you are testing with a admin or developer account.

The phrasing of the error message is a bit misleading/unlucky in that regard.

Ad
source: stackoverflow.com
Ad