From 86692c124bf75acdb8c6a89e98edcc3168084925 Mon Sep 17 00:00:00 2001 From: Varun Varada Date: Tue, 25 Aug 2020 19:28:36 -0500 Subject: [PATCH] Pass HTTP status code to TokenError Previously, when generating error responses, TokenError was not passed the HTTP status code that was passed to the error response handler (parseErrorResponse). This resulted in every kind of error being treated as a 500 Internal Server Error. This commit fixes this by passing on the returned status code from the OAuth call. --- lib/strategy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/strategy.js b/lib/strategy.js index 8ac16e4..8ce43fe 100644 --- a/lib/strategy.js +++ b/lib/strategy.js @@ -355,7 +355,7 @@ OAuth2Strategy.prototype.tokenParams = function(options) { OAuth2Strategy.prototype.parseErrorResponse = function(body, status) { var json = JSON.parse(body); if (json.error) { - return new TokenError(json.error_description, json.error, json.error_uri); + return new TokenError(json.error_description, json.error, json.error_uri, status); } return null; };