MakerLabs ACM
GoogleSigninButton Class Reference

WebComponent which shows a sign-in / sign-out button and triggers a Google Auth popup flow. More...

Inheritance diagram for GoogleSigninButton:

Detailed Description

WebComponent which shows a sign-in / sign-out button and triggers a Google Auth popup flow.

Emits auth-error event if Google Auth API cannot be initialized.
Emits currentUser event with details of current user (name, email, photo).

Public Member Functions

 constructor ()
 
 render ()
 LitElement lifecycle hook. Re-rendered after any update(). More...
 
get cookieWarningDialogMetadata ()
 Returns details to be shown in a dialog to the user regarding enabling 3rd-party cookies support for accounts.google.com. More...
 
async updated (changedProperties)
 LitElement lifecycle hook. Called whenever the element's DOM has been updated and rendered. More...
 
async handleLogin ()
 Trigger a Google Auth popup. More...
 
async handleLogout ()
 Trigger Google Auth sign-out. More...
 
async handleAuthStateChanged (signedIn)
 Extract user details (name, email, photo) from logged-in user. More...
 

Static Public Member Functions

static get properties ()
 WebComponent properties that can be used as HTML attributes. More...
 
static async loadGapi ()
 Create a dynamic <script> element to load Google gapi client library and wait for it to be loaded. More...
 

Member Function Documentation

◆ constructor()

GoogleSigninButton::constructor ( )
inline
Here is the call graph for this function:

◆ cookieWarningDialogMetadata()

get GoogleSigninButton::cookieWarningDialogMetadata ( )
inline

Returns details to be shown in a dialog to the user regarding enabling 3rd-party cookies support for accounts.google.com.

Returns
Object describing the title and helpText of the dialog.

◆ handleAuthStateChanged()

async GoogleSigninButton::handleAuthStateChanged (   signedIn)
inline

Extract user details (name, email, photo) from logged-in user.

Parameters
signedInBoolean to describe whether user is currently signed-in

Dispatch currentUser event with extracted user details.

◆ handleLogin()

async GoogleSigninButton::handleLogin ( )
inline

Trigger a Google Auth popup.

Here is the call graph for this function:

◆ handleLogout()

async GoogleSigninButton::handleLogout ( )
inline

Trigger Google Auth sign-out.

◆ loadGapi()

static async GoogleSigninButton::loadGapi ( )
inlinestatic

Create a dynamic <script> element to load Google gapi client library and wait for it to be loaded.

◆ properties()

static get GoogleSigninButton::properties ( )
inlinestatic

WebComponent properties that can be used as HTML attributes.

Parameters
signedInBoolean to set whether a valid Google Auth user has been logged in
oauthClientIdOAuth Application Client ID
oauthScopesSpace-separated list of OAuth scopes / permissions to be requested
googleAuthInitializedBoolean to set whether Google Auth library has been loaded

◆ render()

GoogleSigninButton::render ( )
inline

LitElement lifecycle hook. Re-rendered after any update().

Returns
LitElement html`` literal, containing desired DOM state.
Here is the call graph for this function:

◆ updated()

async GoogleSigninButton::updated (   changedProperties)
inline

LitElement lifecycle hook. Called whenever the element's DOM has been updated and rendered.

Parameters
changedPropertiesJS Map containing properties which have changed

If Google Auth API has not been initialized, and OAuth client app settings are present:

  • Attempt to load the API.
  • Initialize with OAuth client app details (and scopes).
  • (Dispatch auth-error event with details in case of error).
  • If Google Auth API initialization was successful, trigger reload current login state.
Here is the call graph for this function:

The documentation for this class was generated from the following file: