I'm trying to follow this tutorial https://developers.google.com/identity/sign-in/web/sign-in When i log in, the data-onsuccess doesn't run the onSignIn() fucntion.
i put the script in this Code
ngOnInit() {
this.loadScript('https://apis.google.com/js/platform.js');
}
public loadScript(url: string) {
const body = document.body as HTMLDivElement;
const script = document.createElement('script');
script.innerHTML = '';
script.src = url;
script.async = false;
script.defer = true;
body.appendChild(script);
}
in the same component class I put this inside,
public onSignIn(googleUser) {
const profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
console.log('hi');
}
public signOut() {
const auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then( () => {
console.log('User signed out.');
});
the div tag is as it is in the tutorial,
<div class="g-signin2" data-onsuccess="onSignIn"></div>