diff --git a/src/OAuthClient.js b/src/OAuthClient.js index 9662c002..ee515a2f 100644 --- a/src/OAuthClient.js +++ b/src/OAuthClient.js @@ -585,7 +585,7 @@ OAuthClient.prototype.createError = function createError(e, authResponse) { e.originalMessage = e.message; e.error = ''; - if ('error' in authResponse.getJson()) { + if (authResponse.isJson() && 'error' in authResponse.getJson()) { e.error = authResponse.getJson().error; } else if (authResponse.response.statusText) { e.error = authResponse.response.statusText; @@ -594,7 +594,7 @@ OAuthClient.prototype.createError = function createError(e, authResponse) { } e.error_description = ''; - if ('error_description' in authResponse.getJson()) { + if (authResponse.isJson() && 'error_description' in authResponse.getJson()) { e.error_description = authResponse.getJson().error_description; } else if (authResponse.response.statusText) { e.error_description = authResponse.response.statusText;