Search code examples
javascripthtmlhello.js

How to get user email id using hello.js?


I am trying to login website with hello.js. I get the user name but I can't get user email id. How can I get this?

I am following this link.

This is my code :

<script src="hello.js" ></script>

<script>

hello.init({
    google: "742850147964-r4pfusmgmp2mtfbngh387e30k3692p79.apps.googleusercontent.com"  
}, {redirect_uri: 'index.php'});

hello.on('auth.login', function(auth) {

    // Call user information, for the given network
    hello(auth.network).api('/me').then(function(r) {       
        console.log("r.email = "+r.email);
        console.log("r.name== = "+r.name);
    });
});
</script>

Solution

  • I got my problem solved by simple changing in the hello.js.

    for google :-

    scope: {                
            basic: 'https://www.googleapis.com/auth/plus.me profile',
           }
    

    to

    scope: {                
            basic: 'https://www.googleapis.com/auth/userinfo.email',
           }
    

    for facebook :-

    scope: {                
            basic: 'public_profile',
           }
    

    to

    scope: {                
            basic: 'public_profile,email',
           }