diff --git a/package-lock.json b/package-lock.json index 16a9aad..852ad39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@oat-sa/tao-core-sdk", - "version": "1.18.1", + "version": "1.18.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a70e77a..6429fc6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oat-sa/tao-core-sdk", - "version": "1.18.1", + "version": "1.18.2", "displayName": "TAO Core SDK", "description": "Core libraries of TAO", "homepage": "https://github.com/oat-sa/tao-core-sdk-fe#readme", diff --git a/src/core/tokenHandler.js b/src/core/tokenHandler.js index c14f53e..1d81750 100644 --- a/src/core/tokenHandler.js +++ b/src/core/tokenHandler.js @@ -86,23 +86,25 @@ export default function tokenHandlerFactory(options) { return tokenStore .expireOldTokens() .then(() => { - return tokenStore - .getSize() - .then(queueSize => { - if (queueSize > 0) { - // Token available, use it - return getFirstTokenValue(); - } - - if (!validateTokensOpt || !clientConfigFetched) { - return this - .getClientConfigTokens() - .then(getFirstTokenValue); - } - - // No more token options, refresh needed - return Promise.reject(new Error('No tokens available. Please refresh the page.')); - }); + if (!clientConfigFetched) { + // Client Config allowed! (first and only time) + return this.getClientConfigTokens() + .then(getFirstTokenValue); + } else { + return tokenStore.getSize() + .then(queueSize => { + if (queueSize > 0) { + // Token available, use it + return getFirstTokenValue(); + } else if (!validateTokensOpt) { + return this.getClientConfigTokens() + .then(getFirstTokenValue); + } else { + // No more token options, refresh needed + return Promise.reject(new Error('No tokens available. Please refresh the page.')); + } + }); + } }); },