1.0.9 • Published 4 years ago

exegesis-plugin-google-oauth2 v1.0.9

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

exegesis-plugin-google-oauth2

Run Status Coverage Badge npm.io npm.io npm.io npm.io

Description

Exegesis middleware to handle Google OAuth2 authentication

Installation

npm install exegesis-plugin-google-oauth2

Example

Add this to your Exegesis options:

const exegesisGoogleOAuth2Plugin = require( 'exegesis-plugin-google-oauth2' );

options = {
    plugins: [
        exegesisGoogleOAuth2Plugin({
            // URL path to expose authentication endpoints (default /auth/google)
            path: '/auth/google',

            // Client ID and secret for Google API
            clientId: 'myGoogleClient',
            clientSecret: 'MyClientSecret',

            // Authorization parameters to be passed to Google API (defaults shown)
            authorization: {
                access_type: 'online',
                prompt: 'consent',
                scope: [ 'email', 'profile' ]
            },

            // Options to pass to people.get (see https://developers.google.com/people/api/rest/v1/people/get)
            people: {
                skip: false, // don't call the people API
                resourceName: 'people/me',
                personFields: 'names,nicknames,coverPhotos,emailAddresses'
            },

            // Callback function to handle successful authentication
            // parameters:
            // - context: exegesis context object
            // - tokens: tokens received from Google
            // - me: Google People user profile
            callback: async function( context, tokens, me ) {
                return{
                    id: me.id
                }
            }
        })
    ]
};

The environment variables GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET may also be used to provide the clientId and clientSecret.

If no callback function is provided, the response to successful authentication will be a JSON object:

{
    id: me.id,
    name: me.displayName,
    emails: me.emails,
    image: me.image
}
1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 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