cordova-plugin-facebook-connect / cordova-plugin-facebook-connect

Use the latest Facebook SDK in your Cordova and Ionic projects
Other
63 stars 90 forks source link

Email permission not granted on Android #92

Closed Hissvard closed 2 years ago

Hissvard commented 2 years ago

Bug or feature request

[x] I'm reporting a reproducible issue with the code [ ] I'm reporting a feature request

Describe the Bug of feature request

I'm trying to authenticate a user and get their email address. The issue can be reproduced with the following code:

facebookConnectPlugin.login(['public_profile', 'email', 'user_photos'],
    response => {
        const endpoint = '/' + response.authResponse.userID
            + '/permissions?access_token=' + response.authResponse.accessToken;

        facebookConnectPlugin.api(endpoint, [], 'GET',
            apiResponse => {
                console.log(apiResponse, 'apiResponse');
            }, apiError => {
                console.error(apiError, 'apiError');
            });

        facebookConnectPlugin.api('/me?fields=first_name,last_name,email', [], 'GET',
            apiResponse => {
                console.log(apiResponse, 'fieldsResponse');
            }, apiError => {
                console.error(apiError, 'fieldsError');
            });
    },
    err => console.error(err, 'loginError')
);

// apiResponse
[
    {
        "permission": "public_profile",
        "status": "granted"
    }
]

// fieldsResponse
{
    "first_name": "John",
    "last_name": "Smith",
    "id": "0000000000000000"
}

Expected Behavior

I expect the permissions request to confirm the "email" permission along "public_profile" and the fieldsResponse to contain the email address of the logged in user.

Plugin version, OS, devices, etc

devices: Tested on a Samsung M51 running Android 11 and a Huawei Mate 20 Lite running Android 10 plugin version: 3.0.1 cordova-android version: 9.0.0 cordova version: 10.0.0

Additional Context

I made sure all links to the privacy policy are valid and reviewed and accepted by Facebook. I tried to obtain the email using Facebook's Graph debugger and the user's email is returned.

noahcooper commented 2 years ago

I can't reproduce the issue you're describing. In my testing, when calling the /permissions endpoint the response shows that the "email" permission was granted, and the call to /me?fields=first_name,last_name,email returns the email address.

If you edit your app on https://developers.facebook.com/apps, under App Review -> Permissions and Features, what information displays next to the email permission? Is it set to Standard Access or Advanced Access?

Hissvard commented 2 years ago

Thanks a lot, the problem was exactly that it was set to "Standard Access". I changed it to Advanced Access and it's now working perfectly.

Do you think it would be appropriate mentioning this requirement in the README, maybe next to the documentation for login? I personally barely work with Facebook's APIs so I never got the memo about this change in data access, the email field sounds like something a lot of applications need available.

noahcooper commented 2 years ago

@Hissvard sure, I can update the README to reference the Facebook documentation on access levels.