How to use my Own Google Signin Button in Angular App

Viewed 8

I'm looking for a way to integrate authentication with Google in Application Angular without using Google's origins buttons. I was able to do this by injecting Google SDK code to my personal button in ngOnInit like this:

   (function (d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) {
                return;
            }
            js = d.createElement('script');
            js.id = id;
            js.src = "https://apis.google.com/js/platform.js?onload=googleSDKLoaded";
            fjs?.parentNode?.insertBefore(js, fjs);
        }(document, 'script', 'google-jssdk'));

Unfortunately the script often takes time to load and therefore clicking the button does not always work. What other methods could I try? Thanks !

0 Answers
Related