Retrieve Facebook user details with using Socialite Laravel
Asked Answered
C

4

3

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.

Confound answered 21/6, 2018 at 9:38 Comment(2)
What API version is your app using? Can you show the full login dialog URL please?Thurgau
Sorry, Where i have to check the app version ?? I have take the reference of appdividend.com/2017/07/12/laravel-facebook-loginConfound
T
14

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.

Thurgau answered 21/6, 2018 at 13:48 Comment(3)
Thank you! I have set app mode from live to development mode! Apart from that I have created test users under my developer account and give all the permissions to them now i am able to get all the permissions.Confound
can you please look into this ? #51056570Confound
Why doesn't Facebook say that then instead of that USELESS error message?! It's like assumed knowledge.Onehorse
K
1

You need to explicitly declare scopes you need on your facebook apps page. Open you https://developers.facebook.com/apps/ dashboard, go to app review and submit item you need scope on. After that you need to comply to facebook request usually involved screen capture of login flow and feature usage.

Be noted that this process takes quite a long time. Some of apps I create scheduled to be reviewed on early august.

Kafka answered 21/6, 2018 at 9:47 Comment(7)
@ShashankShah yes. In my experience its stoped retrieving the scope I declare because of those.Kafka
@CBroe owh. Well, okay. My mistake then.Kafka
Do you know anything related to test users ? on Facebook developer account under the role sections -> you may add test users with the permissions.Confound
@ShashankShah yes you could add test user. You could create one through graph api. They have access token and privilege like real user. Very useful on automated test scenario. Check developers.facebook.com/docs/apps/test-usersKafka
It is an invisible account. You could create one through graph api. Mock friend relation between test user and delete them when you are done. Very usefull on automatic testing scenario. Check developers.facebook.com/docs/apps/test-usersKafka
Looks like you were right after all - it seems to be related to review, in that now they even more restricted this, so that your app needs to be in dev mode, otherwise even people with a role in the app can’t be asked for these un-reviewed permissions any more.Thurgau
Can you please look into #51056570 question ?Confound
U
1

user_birthday, user_location, user_friends there are lots of other scopes that needs review from facebook before make it available to public user. However you can use these scopes for developer and test users account.

https://developers.facebook.com/docs/apps/review/

Ultann answered 21/6, 2018 at 10:24 Comment(0)
I
1

This error is because of facebook has updated permissions that you are looking for to new ones refer latest permissions this documentation shows latest permissions and update yours https://developers.facebook.com/docs/facebook-login/permissions

Irrespirable answered 8/5, 2020 at 17:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.