Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcosvidolin/google-idtoken-auth
Node.js middleware to validate Google ID tokens in the request.
https://github.com/marcosvidolin/google-idtoken-auth
auth0 expressjs google idtoken javascript middleware nodejs security token
Last synced: about 1 month ago
JSON representation
Node.js middleware to validate Google ID tokens in the request.
- Host: GitHub
- URL: https://github.com/marcosvidolin/google-idtoken-auth
- Owner: marcosvidolin
- License: mit
- Archived: true
- Created: 2019-01-26T04:25:10.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-09T21:27:56.000Z (over 3 years ago)
- Last Synced: 2024-09-22T08:35:32.144Z (about 2 months ago)
- Topics: auth0, expressjs, google, idtoken, javascript, middleware, nodejs, security, token
- Language: JavaScript
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# google-token-auth
[![npm version](https://badge.fury.io/js/google-idtoken-auth.svg)](https://badge.fury.io/js/google-idtoken-auth) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/49992b6c073648c192662bdd7de6f087)](https://www.codacy.com/app/marcosvidolin/google-idtoken-auth?utm_source=github.com&utm_medium=referral&utm_content=marcosvidolin/google-idtoken-auth&utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/marcosvidolin/google-idtoken-auth.svg?branch=master)](https://travis-ci.org/marcosvidolin/google-idtoken-auth)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
```sh
$ 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
```js
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](https://developers.google.com/identity/sign-in/web/sign-in)
[Authenticate with a backend server](https://developers.google.com/identity/sign-in/web/backend-auth)
## [MIT Licensed](LICENSE)
## Contributors
[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/images/0)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/links/0)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/images/1)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/links/1)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/images/2)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/links/2)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/images/3)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/links/3)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/images/4)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/links/4)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/images/5)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/links/5)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/images/6)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/links/6)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/images/7)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/google-idtoken-auth/links/7)