1.0.14 • Published 5 years ago

tb-vue-google-login v1.0.14

Weekly downloads
14
License
MIT
Repository
github
Last release
5 years ago

Vue google login plugin

Usage

Install in your VueJS project:

npm i -s tb-vue-google-login

Import in main.js and install:

import GoogleLoginPlugin from 'tb-vue-google-login'

Vue.use(GoogleLoginPlugin, { login: "http://your-website.com/api/login" })
// /login will receive { "token": "ejysdfusdh.alfjsdk.sdfsdfds" }

A global google-login-component tag will be installed.

Add the following tags to your index.html:

<meta name="google-signian-scope" content="profile email">
<meta name="google-signin-client_id"
  content="your-client-id.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>

Use google-login-component in any component you wish:

<template>
  <div id="auth-popup">
    <google-login-component
      @loginSuccess="loginSuccessHandler">
    </google-login-component>
  </div>
</template>

And you are good to go!

Emitted events and props:

<template>
  <div id="auth-popup">
    <google-login-component

      @loginSuccess="methodCalledWhenLoginIsCompletedOnYourSite"

      @authSuccess="methodCalledWhenGoogleAuthTokenArrived"

      @loginFail="methodCalledWhenLoginFailedOnYourSite"

      @authFail="methodCalledWhenGoogleAuthFailed">

    </google-login-component>
  </div>
</template>