Nearsighted Prank Master

    vue-gapi
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.0 • Public • Published

    npm vuejs3

    VueGapi

    Google API Client Library wrapper for Vue.js

    Requirements

    Version 2 requires Vue.js v3.x.

    If you are looking for a Vue.js v2.x compatible version, use Version 1.

    Installation

    npm install vue-gapi

    Usage

    Install the plugin with gapi.client.init configuration parameters:

    import { createApp } from 'vue'
    import VueGapi from 'vue-gapi'
    
    const app = createApp({})
    
    app.use(VueGapi, {
      apiKey: '<YOUR_API_KEY>',
      clientId: '<YOUR_CLIENT_ID>.apps.googleusercontent.com',
      discoveryDocs: ['https://sheets.googleapis.com/$discovery/rest?version=v4'],
      scope: 'https://www.googleapis.com/auth/spreadsheets',
    })

    Composition API

    Inject the GoogleAuthService instance via useGapi:

    import { useGapi } from 'vue-gapi'
    
    export default {
      setup() {
        const gapi = useGapi()
    
        function login() {
          gapi.login().then(({ currentUser, gapi, hasGrantedScopes }) => {
            console.log({ currentUser, gapi, hasGrantedScopes })
          })
        }
    
        return { login }
      },
    }

    Options API

    Reference the $gapi global property accessible inside the application:

    export default {
      methods: {
        login() {
          this.$gapi.login().then(({ currentUser, gapi, hasGrantedScopes }) => {
            console.log({ currentUser, gapi, hasGrantedScopes })
          })
        },
      },
    }

    Keywords

    none

    Install

    npm i vue-gapi

    DownloadsWeekly Downloads

    1,309

    Version

    2.1.0

    License

    MIT

    Unpacked Size

    59.2 kB

    Total Files

    8

    Last publish

    Collaborators

    • cedricpoilly