simmatrix / vue-google-auth

[DEPRECATED] Handling Google sign-in and sign-out for Vue.js applications
MIT License
46 stars 45 forks source link

Usage with Nuxt.js #10

Open Chathula opened 6 years ago

Chathula commented 6 years ago

how to use this with nuxt.js

Chathula commented 6 years ago

just found the way...

nuxt.config.js

plugins: [
    { src: '~plugins/google.js', ssr: false, injectAs: 'googleAuth' },
  ]

plugins/google.js

import Vue from 'vue'
import GoogleAuth from 'vue-google-auth'
import { GOOGLE_CLIENT_ID } from '../config/constants'

Vue.use(GoogleAuth, { clientId: GOOGLE_CLIENT_ID })
Vue.googleAuth().load()

export default GoogleAuth

you can now access this inside any vue file

this.$googleAuth().signIn(this.signInCallback, (error) => {
        this.error = 'Google sign in failed'
      });