express-google-oauth
v1.1.0
Published
Authenticate with google (via passport) and grant access to users who match an email whitelist
Downloads
4
Maintainers
Readme
express-google-oauth
Usage
const app = require('express')()
const googleOauth = require('express-google-oauth')
googleOauth(app)
Options
The function can be called with a second options
argument, with the following structure:
{
google: {
// oauth client ID
clientID: string,
// oauth client secret
clientSecret: string,
// callback, as configured in the google oauth console
callbackURL: string
},
routes: {
// route where the oauth flow is initiated
init: string,
// route where the oauth callback is handled
callback: string
// route where successful logins are redirected
success: string,
// route where failed logins are redirected
failure: string
},
// comma-separated list of email addresses of people who are allowed to log in
whitelist: string
}
To keep secrets out of your codebase, it is recommended to use the following ENV variables. If the the options.google
section is undefined, values from process.env
will be used by default:
GOOGLE_CLIENT_ID
becomesopts.google.clientID
GOOGLE_CLIENT_SECRET
becomesopts.google.clientSecret
GOOGLE_CALLBACK_URL
becomesopts.google.callbackURL
The whitelist can also be stored in ENV, since it probably changes from one environment to the next:
GOOGLE_AUTH_WHITELIST
becomesopts.whitelist
License
MIT