1.0.4 • Published 6 years ago

@coolgk/google-sign-in v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

@coolgk/google-sign-in

a javascript / typescript module

npm install @coolgk/google-sign-in

google sign in module which verifies id token and returns account data

Report bugs here: https://github.com/coolgk/node-utils/issues

Examples

const { GoogleSignIn } = require('@coolgk/google-sign-in');
// OR
// import { GoogleSignIn } from '@coolgk/google-sign-in';

const googleSignIn = new GoogleSignIn({
    clientId: '......'
});

const invalidToken = '...';
const validToken = '...';

(async () => {
    const account1 = await googleSignIn.verify(invalidToken);
    console.log(account1); // false

    const account2 = await googleSignIn.verify(validToken);
    console.log(account2);
    // {
    //     azp: '...',
    //     aud: '...',
    //     sub: '123123123',
    //     email: 'abc@exmaple.com',
    //     email_verified: true,
    //     at_hash: 'asdfasdfasdfasdfa',
    //     exp: 1520633389,
    //     iss: 'accounts.google.com',
    //     jti: 'qfwfasdfasdfasdfasdfasdfasdfadsf',
    //     iat: 1520629789,
    //     name: 'first last',
    //     picture: 'https://lh6.googleusercontent.com/.../photo.jpg',
    //     given_name: 'first',
    //     family_name: 'last',
    //     locale: 'en-GB'
    // }
})()

GoogleSignIn

Kind: global class
Export:

googleSignIn.verify(token) ⇒ Promise.<(boolean|object)>

Kind: instance method of GoogleSignIn
Returns: Promise.<(boolean|object)> - - false if id token is invalid otherwise returns account data

ParamTypeDescription
tokenstringgoogle id token string

GoogleSignIn.GoogleSignIn

Kind: static class of GoogleSignIn

new GoogleSignIn(options)

ParamTypeDescription
optionsobject
options.clientIdstringgoogle client id
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago