Skip to content
This repository was archived by the owner on Jan 5, 2022. It is now read-only.

marcosvidolin/google-idtoken-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google-token-auth

npm version Codacy Badge Build Status

Node.js middleware to validate Google ID Tokens in the backend server. Validade the request token, get all the Google ID Token fields and populate the req.googleProfileInfo.

Installation

$ npm install google-idtoken-auth

Options

Propertie Type Default Required Description
clientId String true Specify the Google Client ID
tokenHeaderName String x-googleid-token false Custom header name to retrievi the Google ID Token
gSuiteDomains Array false Specify a G Suite domain

Example

var express = require('express');
var googleAuth = require('google-idtoken-auth');

var googleTokenVerifier = googleAuth.googleIdTokenVerifier({
    clientId: "YOUR-GOOGLE-CLIENT-ID"
});

var app = express();
app.use(googleTokenVerifier);

app.get('/', function (req, res) {
  // Get the e-mail from google (email OAuth scope)
  console.log('User e-mail: ', req.googleProfileInfo.email);
});

app.listen(8080);

// curl command that sends an HTTP request with a valid Google ID Token
// curl -H "x-googleid-token: {GOOGLE-ID-TOKEN-HERE}" http://127.0.0.1:8080

See more

Google Sign-In

Authenticate with a backend server

Contributors

About

Node.js middleware to validate Google ID tokens in the request.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •