client-oauth2
Advanced tools
Comparing version 3.0.1 to 3.0.2
{ | ||
"name": "client-oauth2", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Straight-forward execution of OAuth 2.0 flows and authenticated API requests", | ||
@@ -5,0 +5,0 @@ "main": "src/client-oauth2.js", |
@@ -50,3 +50,2 @@ # Client OAuth 2.0 | ||
* **headers** An object to merge with the headers of every request | ||
* **transport** Change certain request transport behaviour (currently `rejectUnauthorized` and `agent`) | ||
@@ -53,0 +52,0 @@ To re-create an access token instance and make requests on behalf on the user, you can create an access token instance by using the `createToken` method on a client instance. |
@@ -137,2 +137,16 @@ var extend = require('xtend') | ||
/** | ||
* Attempt to parse response body as JSON, fall back to parsing as a query string. | ||
* | ||
* @param {String} body | ||
* @return {Object} | ||
*/ | ||
function parseResponseBody (body) { | ||
try { | ||
return JSON.parse(body) | ||
} catch (e) { | ||
return Querystring.parse(body) | ||
} | ||
} | ||
/** | ||
* Sanitize the scopes option to be a string. | ||
@@ -202,4 +216,3 @@ * | ||
query: extend(options.query, requestOptions.query), | ||
headers: extend(options.headers, requestOptions.headers), | ||
transport: extend(options.transport, requestOptions.transport) | ||
headers: extend(options.headers, requestOptions.headers) | ||
}) | ||
@@ -272,12 +285,6 @@ } | ||
err.status = res.status | ||
err.body = res.body | ||
err.body = parseResponseBody(res.body) | ||
return Promise.reject(err) | ||
} | ||
// Attempt to parse as JSON, fall back to parsing as a query string. | ||
try { | ||
return JSON.parse(res.body) | ||
} catch (e) { | ||
return Querystring.parse(res.body) | ||
} | ||
return parseResponseBody(res.body) | ||
}) | ||
@@ -322,3 +329,3 @@ } | ||
* | ||
* @param {Object} requestOptions | ||
* @param {Object} requestObject | ||
* @return {Object} | ||
@@ -325,0 +332,0 @@ */ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
659
29214
185