Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-oauth-jwt

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-oauth-jwt - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

16

lib/auth.js
var fs = require('fs'),
crypto = require('crypto'),
request = require('request');
request = require('request'),
debug = require('debug')('google-oauth-jwt');

@@ -32,6 +33,10 @@ // constants

}, function (err, res, body) {
if (err) {
return callback(err);
} else if (res.statusCode != 200) {
} else {
debug('response from OAuth server: HTTP %d -> %j', res.statusCode, body);
}
if (res.statusCode != 200) {
err = new Error(

@@ -78,2 +83,4 @@ 'failed to obtain an authentication token, request failed with HTTP code ' +

debug('generating jwt for %j', options);
var iat = Math.floor(new Date().getTime() / 1000),

@@ -96,3 +103,3 @@ exp = iat + Math.floor((options.expiration || 60 * 60 * 1000) / 1000),

unsignedJWT = [JWT_header, JWT_claimset].join('.');
obtainKey(function (err, key) {

@@ -109,2 +116,3 @@

debug('signed jwt: %s', signedJWT);
return callback(null, signedJWT);

@@ -111,0 +119,0 @@

@@ -0,1 +1,3 @@

var debug = require('debug')('google-oauth-jwt');
/**

@@ -87,2 +89,3 @@ * A cache of tokens for reusing previously requested tokens until they expire.

this.status = 'expired';
debug('token is expired, a new token will be requested');
this.get(callback);

@@ -89,0 +92,0 @@ } else {

{
"name": "google-oauth-jwt",
"version": "0.1.0",
"author": {
"name": "Nicolas Mercier",
"email": "nicolas@extrabacon.net"
},
"description": "Implementation of Google OAuth 2.0 for server-to-server interactions, allowing secure use of Google APIs without interaction from an end-user.",
"keywords": [
"google",
"api",
"oauth",
"oauth2",
"service account",
"jwt",
"token",
"server to server"
],
"dependencies": {
"request": "*"
},
"devDependencies": {
"name": "google-oauth-jwt",
"version": "0.1.1",
"author": {
"name": "Nicolas Mercier",
"email": "nicolas@extrabacon.net"
},
"description": "Implementation of Google OAuth 2.0 for server-to-server interactions, allowing secure use of Google APIs without interaction from an end-user.",
"keywords": [
"google",
"api",
"oauth",
"oauth2",
"service account",
"jwt",
"token",
"server to server"
],
"dependencies": {
"request": "*",
"debug": "~0.7.2"
},
"devDependencies": {
"underscore": "*",
"async": "*",
"mocha": "*",
"chai": "*",
"chai-spies": "*"
},
"scripts": {
"test": "mocha test/*.js -t 5000"
},
"repository": {
"type": "git",
"url": "http://github.com/extrabacon/google-oauth-jwt"
},
"homepage": "http://github.com/extrabacon/google-oauth-jwt",
"bugs": "http://github.com/extrabacon/google-oauth-jwt/issues",
"engines": {
"node": ">=0.8"
}
"mocha": "*",
"chai": "*",
"chai-spies": "*"
},
"scripts": {
"test": "mocha test/*.js -t 5000"
},
"repository": {
"type": "git",
"url": "http://github.com/extrabacon/google-oauth-jwt"
},
"homepage": "http://github.com/extrabacon/google-oauth-jwt",
"bugs": "http://github.com/extrabacon/google-oauth-jwt/issues",
"engines": {
"node": ">=0.8"
}
}

@@ -72,3 +72,3 @@ # google-oauth-jwt

In this example, we use a modified instance of [request](https://github.com/mikeal/request) to query the
Google Drive API. `request` is a full-featured HTTP client which will be augmented with Google OAuth2 capabilities by using the `requestWithJWT` method. The modified module will request and cache tokens automatically when supplied with a `jwt` setting in the options.
Google Drive API. [request](https://github.com/mikeal/request) is a full-featured HTTP client which can be extended with Google OAuth2 capabilities by using the `requestWithJWT` method. The modified module will request and cache tokens automatically when supplied with a `jwt` setting in the options.

@@ -94,5 +94,4 @@ ```javascript

Note that the `options` object includes a `jwt` object we use to configure how to encode the JWT. The token will then
automatically be requested and inserted in the authorization header for this API call. It will also be cached and
reused for subsequent calls using the same service account and scopes.
Note that the `options` object includes a `jwt` object we use to configure the JWT generation. The token will then
automatically be requested and inserted in the authorization header. It will also be cached and reused for subsequent calls using the same service account and scopes.

@@ -243,4 +242,16 @@ If you want to use a specific version of `request`, simply pass it to the the `requestWithJWT` method as such:

## Debugging
To turn on debugging, add "google-oauth-jwt" to your `DEBUG` variable. Debugging events include JWT generation, token
requests to the OAuth server and token expirations through `TokenCache`.
For example, to turn on debugging while running the unit tests, use this:
```bash
DEBUG=google-oauth-jwt mocha -t 5000
```
## Changelog
* 0.1.1: re-introduced debugging, now with [debug](https://github.com/visionmedia/debug)
* 0.1.0: improved documentation, introduced unit tests and refactoring aimed at testability

@@ -247,0 +258,0 @@ * 0.0.7: fixed token expiration check

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc