From 6d9f6b675e3e213640b9460c4221f029f68006c2 Mon Sep 17 00:00:00 2001 From: Luis Deschamps Rudge Date: Mon, 24 Sep 2018 10:59:19 -0300 Subject: [PATCH] create jwksClient in the constructor --- src/auth/OAUthWithIDTokenValidation.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/auth/OAUthWithIDTokenValidation.js b/src/auth/OAUthWithIDTokenValidation.js index 3d8c66a06..b9833f948 100644 --- a/src/auth/OAUthWithIDTokenValidation.js +++ b/src/auth/OAUthWithIDTokenValidation.js @@ -35,6 +35,9 @@ var OAUthWithIDTokenValidation = function(oauth, options) { this.clientSecret = options.clientSecret; this.domain = options.domain; this.supportedAlgorithms = options.supportedAlgorithms || ['HS256', 'RS256']; + this._jwksClient = jwksClient({ + jwksUri: 'https://' + options.domain + '/.well-known/jwks.json' + }); }; /** @@ -57,9 +60,7 @@ OAUthWithIDTokenValidation.prototype.create = function(params, data, cb) { if (header.alg === 'HS256') { return callback(null, Buffer.from(_this.clientSecret, 'base64')); } - jwksClient({ - jwksUri: 'https://' + _this.domain + '/.well-known/jwks.json' - }).getSigningKey(header.kid, function(err, key) { + _this._jwksClient.getSigningKey(header.kid, function(err, key) { if (err) { return callback(err); }