diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c22bb6..1ef8943 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Fix undefined token in `auth.checkBearerToken()` after a token refresh. + ## v3.3.3 Sugar client updated to decaffeinated version. diff --git a/lib/auth.js b/lib/auth.js index 80dd8ad..ab6fc50 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -77,13 +77,16 @@ const authClient = new Model({ .then(function(request) { var token = this._handleNewBearerToken(request); console.info('Refreshed bearer token', token.slice(-6)); + return token; }.bind(this)) .catch(function(request) { console.error('Failed to refresh bearer token'); apiClient.handleError(request); + return ''; }) - .then(function() { + .then(function(token) { this._tokenRefreshPromise = null; + return token }.bind(this)); }