abacritt / angularx-social-login

Social login and authentication module for Angular 17
630 stars 388 forks source link

Where does `google` object come from? #678

Closed minicatsCB closed 1 year ago

minicatsCB commented 1 year ago

Hello, I have a newbie question just out of curiosity.

While I was exploring the lib code I found the line that renders the Google Sign-In Button. I guess that the google object comes from the Google Identity Service (aka. "GSI") JavaScript client downloaded from https://accounts.google.com/gsi/client as done here.

However, I expected somewhere in the app something like const google: any = google;. I mean, I guess that the GSI script is responsible of declaring itself as a global variable, so we can access them straightforward and don't need to store it in our own variable in order to use it. But how are we sure that when we want to use the google object, it is already available (i.e. the GSI script has finished downloading and executing)? I recently saw this example that uses declare var google: any at the top of an Angular *.component.ts file.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.