javascriptfacebookauthenticationpermissionsfacebook-java-api

Renew users permission Facebook


I have a slight problem with user permissions in my Facebook login flow. I am able to ask for permissions only during first login to my App. But problem is if user logged into app remove permission for email address in his Facebook settings. I am not able to get this permission back and i am getting undefined email address. How can i check permissions during loggin a in some cases ask these permissions back ? Can someone help me ? Thank you very much


Solution

  • You can use return_scopes to get the list of authorized permissions in the login process:

    FB.login(function(response) {
        if (response.authResponse) {
            //user just authorized your app
            console.log(response);
        }
    }, {scope: 'email,public_profile', return_scopes: true});
    

    You can get the currently authorized permissions with /me/permissions: https://developers.facebook.com/docs/graph-api/reference/user/permissions

    If you want to re-authorize permissions later, try to use FB.login with the permissions again. Just use "rerequest":

    FB.login(function(response) {
        if (response.authResponse) {
            //user just authorized your app
            console.log(response);
        }
    }, {scope: 'email,public_profile', auth_type: 'rerequest'});
    

    More information: