npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-google-oauth2

v1.0.7

Published

Handling Google sign-in and sign-out for Vue3 applications.

Downloads

4,073

Readme

DEPRECATED - no longer actively maintained

You can use this plugin vue3-google-login instead to have support for the new Google Identity Services JavaScript library.

vue3-google-oauth2

Handling Google sign-in and sign-out for Vue3 applications.

Please refer to here for Vue2 applications.

npm bundle size GitHub vue3-google-oauth2

Front-end Demo

Installation

Installation with npm

npm install vue3-google-oauth2

Installation with yarn

yarn add vue3-google-oauth2

Initialization

import { createApp } from 'vue'
import App from './App.vue'
import GAuth from 'vue3-google-oauth2'
const app = createApp(App)

const gAuthOptions = { clientId: 'YOUR_CLIENT_ID', scope: 'email', prompt: 'consent', fetch_basic_profile: false }
app.use(GAuth, gAuthOptions)

Options

| Property | Type | Required | Description | |--------------|----------|-----------------|-----------------| | clientId | String | Required. | The app's client ID, found and created in the Google Developers Console. | | scope | String | Optional. | Default value is profile email. Full list of scopes. | | prompt | String | Optional. | This value using for authCode. The possible values are select_account or consent. Default value is select_account. To get refresh token from auth code, use consent.| | fetch_basic_profile | Boolean | Optional. | If set to true, email profile openid will be automatically added as scope. Default value is true. |

Methods

| Property | Description | Type | |--------------|--------------------|----------| | instance | return of gapi.auth2.getAuthInstance() | Object | | signIn | function for sign-in | Function | | getAuthCode | function for getting authCode | Function | | signOut | function for sign-out | Function |

Reactivity

We support reactivity by Provide/Injection. Refer to sample project.

| Property | Description | Type | |--------------|--------------------|----------| | Vue3GoogleOauth.isInit | it will return reactivity object value({isInit, isAuthorized}) | Object | | Vue3GoogleOauth.isAuthorized | it will return reactivity object value({isInit, isAuthorized}) | Object |

Usages

Refer to sample project.

Extra - Directly get access_token and refresh_token on Server-side

To get access_token and refresh_token in server side, the data for redirect_uri should be postmessage. postmessage is magic value for redirect_uri to get credentials without actual redirect uri.

Curl

curl -d "client_id=YOUR_CLIENT_ID&\
  client_secret=YOUR_CLIENT_SECRET&\
  redirect_uri=postmessage&\
  grant_type=authorization_code&\
  code=YOUR_AUTH_CODE" https://accounts.google.com/o/oauth2/token

Sample Code

Additional Help

FAQ

The failure of initialization happens

You can check the brower console to check errors which occur during initialization. The most of errors are from inproper setting of google oauth2 credentials setting in Google Developer Console. After changing the settings, you have to do hard refresh to clear your caches.