Fetch the user information with the permission into facebook instant game

1.5k views Asked by At

Please help me regarding my query.

I make an instant game and into that game i want the user (player) information ( like email, gender,birthday and location).

I use below following code to get the information but not working here is the code:

window.fbAsyncInit = function () {

        FB.init({
            appId: '<app_id>',
            cookie: true,
            xfbml: true,
            version: 'v3.2'
        });

        FB.AppEvents.logPageView();

        function onLogin(response) {
            if (response.status == 'connected') {
                FB.api('/me?fields=id,name,birthday,gender,installed,email', function (data) {
                    console.log('Hello, ' + data.first_name + '!');
                });
            } else {
                console.log('User cancelled login or did not fully authorize.');
            }
        }

        FB.getLoginStatus(function (response) {
            // Check login status on load, and if the user is
            // already logged in, go directly to the welcome message.
            if (response.status == 'connected') {
                onLogin(response);
            } else {
                // Otherwise, show Login dialog first.
                FB.login(function (response) {
                    onLogin(response);
                }, {scope: 'email'});
            }
        });
};

but when i run this code into the IG then error occurred- The operation is insecure.

Please help me provide a solution that can i fetch the user information with the permission.

here the below following steps:

a) on Facebook developer account create an app

b) then add product Facebook login

c) and also app center - here add the permission that want to ask from user.

d) after that open the application page where the below

App url https://www.facebook.com/games/app_namespace : show these permisions

1

There are 1 answers

2
Chris Hawkins On

You cannot use the Facebook login SDK inside Instant Games. You must use the relevant FBInstant methods (e.g. FBInstant.player.getName()) to get player information. It is currently not possible to access the player’s email address and gender from within Instant Games.