Search code examples
javascriptgoogle-apigoogle-plushello.js

Google Sign in Returning 'Undefined" for Username with Hello.js


So I am using hello.js http://adodson.com/hello.js/ to create social login buttons for my application.

Works great and I have FB, LinkedIn and Twitter up and running. For Google however I have a slight issue.

It allows me to log in using my Google credentials, however, instead of displaying my username and profile picture where it should, I instead get 'undefined' and a missing image.

Here is my code

hello.init({
facebook: 'xxxx',
linkedin: 'xxxx',
twitter: 'xxxx',
google: 'xxxx'

}, {
redirect_uri: 'redirect.html'
});

hello.on('auth.login', function(auth){
// Get Profile
hello.api(auth.network+':/me', function(p){
        document.getElementById('social-details').innerHTML = "<img src='"+ p.thumbnail 
        +    "' width=50/><br/><p class='lead text-primary'>Connected to "+ auth.network + " as " + p.name + "</p>";
});

});

The keys and redirect are all working.

Any help would be much appreciated!


Solution

  • Missed a very basic step - I did not enable the Google Plus API for my Google Application.

    Once I enabled it from the Google Developers Console it worked fine.

    Hopefully this will help somebody who encounters the same problem!

    Thanks to all who took the time to look at my question.