index
GoogleAuthService
- GoogleAuthService
- new GoogleAuthService()
- .getGapiClient() ⇒
Promise.<gapi>
- .getAuthInstance() ⇒
Promise.<GoogleAuth>
- .getCurrentUser() ⇒
Promise.<GoogleUser>
- .getOfflineAccessCode() ⇒
string
|null
- .grantOfflineAccess() ⇒
Promise.<string>
- .login([options]) ⇒
Promise.<LoginResponse>
- .refreshToken() ⇒
Promise.<AuthResponse>
- .grant() ⇒
Promise.<GoogleUser>
- .logout() ⇒
Promise
- .isAuthenticated() ⇒
boolean
- .isSignedIn() ⇒
Promise.<boolean>
- .listenUserSignIn(callback) ⇒
Promise.<void>
- .getUserData() ⇒
UserData
|null
- .gapi
- .GoogleAuth
- .GoogleUser
- .LoginOptions
- .LoginResponse
- .UserData :
object
new GoogleAuthService()
Exposed as a $gapi
global property accessible inside the application.
Promise.<gapi>
.getGapiClient() ⇒ Returns an initialized gapi client.
See: https://github.com/google/google-api-javascript-client/blob/master/docs/start.md
Promise.<GoogleAuth>
.getAuthInstance() ⇒ Returns the GoogleAuth object.
See: gapi.auth2.getAuthInstance
Since: 1.0.0
Promise.<GoogleUser>
.getCurrentUser() ⇒ Returns a GoogleUser object that represents the current user.
See: GoogleAuth.currentUser.get
Since: 1.0.0
string
| null
.getOfflineAccessCode() ⇒ Returns the authorization code set via grantOfflineAccess.
Promise.<string>
.grantOfflineAccess() ⇒ Get permission from the user to access the specified scopes offline.
Returns: Promise.<string>
- authorization code
See: GoogleAuth.grantOfflineAccess
Promise.<LoginResponse>
.login([options]) ⇒ Signs in the user and initializes session.
See: GoogleAuth.signIn
Param | Type |
---|---|
[options] | LoginOptions |
Promise.<AuthResponse>
.refreshToken() ⇒ 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.reloadAuthResponse
Example
// NOTE: 45min refresh policy is what google recommends
window.setInterval(this.$gapi.refreshToken(), 2.7e+6)
Promise.<GoogleUser>
.grant() ⇒ Ask to grant scopes from user.
See: GoogleUser.grant
Since: 0.4.0
Promise
.logout() ⇒ Signs out the current account from the application and clear session storage.
See: GoogleAuth.signOut
boolean
.isAuthenticated() ⇒ Determines if the user is signed in via local storage.
Promise.<boolean>
.isSignedIn() ⇒ Determines if the user is signed in via Google.
See: GoogleUser.isSignedIn
Since: 0.0.10
Promise.<void>
.listenUserSignIn(callback) ⇒ Accept the callback to be notified when the authentication status changes.
See: GoogleAuth.isSignedIn.listen
Since: 0.0.10
Param | Type | Description |
---|---|---|
callback | function | the callback function to be notified of an authentication status change |
UserData
| null
.getUserData() ⇒ Gets the user data from local storage
.gapi
Google API Client.
See: https://github.com/google/google-api-javascript-client
.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#authentication
.GoogleUser
Object that represents the current user.
See: https://developers.google.com/identity/sign-in/web/reference#googleusergetid
.LoginOptions
Properties
Name | Type | Default | Description |
---|---|---|---|
[grantOfflineAccess] | boolean | false | Additionally gets permission from the user to access the specified scopes offline via getOfflineAccessCode |
.LoginResponse
Properties
Name | Type | Description |
---|---|---|
currentUser | GoogleUser | Current user |
gapi | gapi | Initialized gapi client |
hasGrantedScopes | boolean | true if the requested scopes were granted. |
[code] | string | Authorization code if grantOfflineAccess: true |
object
.UserData : See
Properties
Name | Type | Description |
---|---|---|
id | string | user's unique ID string |
firstName | string | given name |
lastName | string | family name |
fullName | string | full name |
string | ||
imageUrl | string | |
expiresAt | number | |
accessToken | string | granted access token |
idToken | string | granted ID token |
[offlineAccessCode] | string |