• Stars
    star
    288
  • Rank 143,818 (Top 3 %)
  • Language
    JavaScript
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ” A simple Vue plugin to include a Google sign-in button into your web app.

vue-google-signin-button

A simple Vue plugin to include a Google sign-in button into your web app.

Screenshot

Install

This plugin can be installed as a module

$ npm install vue-google-signin-button

or, if you're not in a modular environment, just include it as a <script>.

Usage

Important: https://apis.google.com/js/api:client.js must be included as a <script> in your web app, as this plugin depends on it.

Step 1: import and use the plugin if you're in a modular environment (you don't need this step otherwise, as the plugin will register itself).

import GSignInButton from 'vue-google-signin-button'
Vue.use(GSignInButton)

Step 2: Now you have a g-signin-button global component, ready for use. It's best to demonstrate the usage with an example:

<template>
  <g-signin-button
    :params="googleSignInParams"
    @success="onSignInSuccess"
    @error="onSignInError">
    Sign in with Google
  </g-signin-button>
</template>

<script>
export default {
  data () {
    return {
      /**
       * The Auth2 parameters, as seen on
       * https://developers.google.com/identity/sign-in/web/reference#gapiauth2initparams.
       * As the very least, a valid client_id must present.
       * @type {Object}
       */
      googleSignInParams: {
        clientId: 'YOUR_APP_CLIENT_ID.apps.googleusercontent.com'
      }
    }
  },
  methods: {
    onSignInSuccess (googleUser) {
      // `googleUser` is the GoogleUser object that represents the just-signed-in user.
      // See https://developers.google.com/identity/sign-in/web/reference#users
      const profile = googleUser.getBasicProfile() // etc etc
    },
    onSignInError (error) {
      // `error` contains any error occurred.
      console.log('OH NOES', error)
    }
  }
}
</script>

<style>
.g-signin-button {
  /* This is where you control how the button looks. Be creative! */
  display: inline-block;
  padding: 4px 8px;
  border-radius: 3px;
  background-color: #3c82f7;
  color: #fff;
  box-shadow: 0 3px 0 #0f69ff;
}
</style>

That's it!

Looking for the Facebook counterpart?

License

MIT Β© Phan An

More Repositories

1

htaccess

βœ‚A collection of useful .htaccess snippets.
12,497
star
2

kupo

βœ… Simple site launch checklist checker/validator.
PHP
382
star
3

vue-facebook-signin-button

A simple plugin to include a custom Facebook sign-in button into your web app.
JavaScript
135
star
4

vue-linkify

A simple Vue directive to turn URL's and emails into clickable links
JavaScript
81
star
5

vue-snippets

βœ‚οΈA collection of Vue snippets
CSS
81
star
6

tieqviet

A trivial module to convert Vietnamese into the new, experimental, IPA
JavaScript
74
star
7

cascading-config

Bringing the cascading configuration system back to Laravel 5 and its sister project, Lumen.
PHP
55
star
8

factoria

Simplistic model factory for Node/JavaScript
TypeScript
51
star
9

slider-puzzle

A simple slider puzzle built with Vue
JavaScript
49
star
10

vuequery

Traverse Vue's component tree with ease.
TypeScript
40
star
11

remote

Simple remote connection / SFTP / SSH for Laravel 5
PHP
31
star
12

vue-fractal

An attempt to port https://github.com/Swizec/react-fractals/ into Vue
JavaScript
30
star
13

vue-test-helpers

Some helpers for vue-test-utils
JavaScript
30
star
14

tieqviet-demo

Demo for tieqviet module
Vue
28
star
15

phanan.net

🏑 My homepage, built on Nuxt.js
Vue
9
star
16

redmine_webhook

A Redmine plugin posts webhook on creating and updating tickets, originally forked from @sue
Ruby
8
star
17

vuebus

A simple event bus in Vue 2.x
TypeScript
8
star
18

til

The source code for https://til.phanan.net
HTML
7
star
19

laravel-5-cascading-config

Re-enable cascading configuration system in Laravel 5
PHP
7
star
20

smart-playlist-creator

A PoC smart playlist creator (Γ  la iTunes / Winamp)
Vue
6
star
21

log

A minimal WordPress theme
PHP
6
star
22

virtualmin-nginx-config-hook

A Virtualmin hook to generate a nginx server config file post Apache server setup
Shell
4
star
23

unit-test-async-component

A demo on how to unit test Vue async components with Vue Test Utils
Vue
4
star
24

vite-playground

Vue
2
star
25

counter-meetup

The repo for the first Vue meetup
JavaScript
2
star
26

vue-jquery-mask

A demo repo for Vue+jquery-mask
JavaScript
2
star
27

translation-sample

2
star
28

laravel-attr-bug

PHP
1
star