I am using Hello.js for social login in my website . I am using a standard code that has been provided in the documentation HERE.
my code looks something like this
<script>
//user;
hello.on('auth.login', function (auth) {
// call user information, for the given network
hello(auth.network).api('/me').then(function (r) {
// Inject it into the container
//alert(r.name);
window.user = r.email;
window.im_name = r.name;
if (r.email) ajax1();
});
});
hello.init({
facebook: 'xxxxxxxxxxxxxxxxx',
google: 'xxxxxxxxxxxxxxxxxxxxxx5-q6xxxxxxxxxxxxxxxeusercontent.com',
}, {
redirect_uri: 'http://wstation.yzx.com/',
scope: 'email'
});
</script>
HTML
<button class="btn-fb" onclick="hello( 'facebook' ).login()">Facebook</button>
<button class="btn-google" onclick="hello( 'google' ).login()">Google</button>
Every thing is working fine I am able to login through Facebook and then send the credentials to the server to sign in the user. But after the user sign in . The Ajax1()
method is called again and again all the time.
I am trying to read through the Documentation but nothing is helping out
UPDATE
I changed the code into something like this
function connect(x){
hello(x).api("/me").then(function(r){
window.user = r.email;
window.im_name = r.name;
if (r.email) ajax1();
}, function(e){
alert("Whoops! " + e.error.message );
});
}
and HTML
<button class="btn-fb" onclick="connect('facebook')">Facebook</button>
<button class="btn-google" onclick="connect('google')">Google</button>
Now I am getting error
Whoops! Error validating access token: This may be because the user logged out or may be due to a system error.
as an alert
Please help me if any one had same problem
Thanks in advance
I got it worked Hopefully it helps some one else having the same problem
Thanks & Regards