index

GoogleAuthService

new GoogleAuthService()

Exposed as a $gapi global propertyopen in new window accessible inside the application.

.getGapiClient() ⇒ Promise.<gapi>

Returns an initialized gapi client.

See: https://github.com/google/google-api-javascript-client/blob/master/docs/start.mdopen in new window

.getAuthInstance() ⇒ Promise.<GoogleAuth>

Returns the GoogleAuth object.

See: gapi.auth2.getAuthInstanceopen in new window
Since: 1.0.0

.getCurrentUser() ⇒ Promise.<GoogleUser>

Returns a GoogleUser object that represents the current user.

See: GoogleAuth.currentUser.getopen in new window
Since: 1.0.0

.getOfflineAccessCode() ⇒ string | null

Returns the authorization code set via grantOfflineAccess.

.grantOfflineAccess() ⇒ Promise.<string>

Get permission from the user to access the specified scopes offline.

Returns: Promise.<string> - authorization code
See: GoogleAuth.grantOfflineAccessopen in new window

.login([options]) ⇒ Promise.<LoginResponse>

Signs in the user and initializes session.

See: GoogleAuth.signInopen in new window

ParamType
[options]LoginOptions

.refreshToken() ⇒ Promise.<AuthResponse>

Forces a refresh of the access token.

This should be placed in your App.vue on the created page and run on a timer of 45min.

See: GoogleUser.reloadAuthResponseopen in new window
Example

// NOTE: 45min refresh policy is what google recommends
window.setInterval(this.$gapi.refreshToken(), 2.7e+6)

.grant() ⇒ Promise.<GoogleUser>

Ask to grant scopes from user.

See: GoogleUser.grantopen in new window
Since: 0.4.0

.logout() ⇒ Promise

Signs out the current account from the application and clear session storage.

See: GoogleAuth.signOutopen in new window

.isAuthenticated() ⇒ boolean

Determines if the user is signed in via local storage.

Since: 0.0.10

.isSignedIn() ⇒ Promise.<boolean>

Determines if the user is signed in via Google.

See: GoogleUser.isSignedInopen in new window
Since: 0.0.10

.listenUserSignIn(callback) ⇒ Promise.<void>

Accept the callback to be notified when the authentication status changes.

See: GoogleAuth.isSignedIn.listenopen in new window
Since: 0.0.10

ParamTypeDescription
callbackfunctionthe callback function to be notified of an authentication status change

.getUserData() ⇒ UserData | null

Gets the user data from local storage

Since: 0.0.10

.gapi

Google API Client.

See: https://github.com/google/google-api-javascript-clientopen in new window

.GoogleAuth

Singleton class that provides methods to allow the user to sign in with a Google account, get the user's current sign-in status, get specific data from the user's Google profile, request additional scopes, and sign out from the current account.

See: https://developers.google.com/identity/sign-in/web/reference#authenticationopen in new window

.GoogleUser

Object that represents the current user.

See: https://developers.google.com/identity/sign-in/web/reference#googleusergetidopen in new window

.LoginOptions

Properties

NameTypeDefaultDescription
[grantOfflineAccess]booleanfalseAdditionally gets permission from the user to access the specified scopes offline via getOfflineAccessCode

.LoginResponse

Properties

NameTypeDescription
currentUserGoogleUserCurrent user
gapigapiInitialized gapi client
hasGrantedScopesbooleantrue if the requested scopes were granted.
[code]stringAuthorization code if grantOfflineAccess: true

.UserData : object

See

Properties

NameTypeDescription
idstringuser's unique ID string
firstNamestringgiven name
lastNamestringfamily name
fullNamestringfull name
emailstring
imageUrlstring
expiresAtnumber
accessTokenstringgranted access token
idTokenstringgranted ID token
[offlineAccessCode]string