From ca4cd2e42e8d12d3dbd37378d055e714161162b1 Mon Sep 17 00:00:00 2001 From: Frederic Van der essen Date: Mon, 26 Sep 2016 13:09:25 +0200 Subject: [PATCH] Add a configuration option for the refresh token requests --- doc/refresh_token.md | 2 ++ src/authService.js | 5 +++-- src/baseConfig.js | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/refresh_token.md b/doc/refresh_token.md index 148b88e..97e3be6 100644 --- a/doc/refresh_token.md +++ b/doc/refresh_token.md @@ -25,6 +25,8 @@ autoUpdateToken: true, clientId: false, // The the property from which to get the refresh token after a successful token refresh refreshTokenProp: 'refresh_token', +// The proprety name used to send the existing token when refreshing `{ "refreshTokenSubmitProp": '...' }` +refreshTokenSubmitProp = 'refresh_token'; // If the property defined by `refreshTokenProp` is an object: // ----------------------------------------------------------- diff --git a/src/authService.js b/src/authService.js index 72004b7..a0844e4 100644 --- a/src/authService.js +++ b/src/authService.js @@ -314,12 +314,13 @@ export class AuthService { } if (this.authentication.updateTokenCallstack.length === 0) { - const content = { + let content = { grant_type: 'refresh_token', - refresh_token: this.authentication.getRefreshToken(), client_id: this.config.clientId ? this.config.clientId : undefined }; + content[this.config.refreshTokenSubmitProp] = this.authentication.getRefreshToken(); + this.client.post(this.config.joinBase(this.config.refreshTokenUrl ? this.config.refreshTokenUrl : this.config.loginUrl), content) diff --git a/src/baseConfig.js b/src/baseConfig.js index 1f0e9d0..9eb0aa1 100644 --- a/src/baseConfig.js +++ b/src/baseConfig.js @@ -120,6 +120,8 @@ export class BaseConfig { clientId = false; // The the property from which to get the refresh token after a successful token refresh. Can also be dotted eg "refreshTokenProp.refreshTokenProp" refreshTokenProp = 'refresh_token'; + // The proprety name used to send the existing token when refreshing `{ "refreshTokenSubmitProp": '...' }` + refreshTokenSubmitProp = 'refresh_token'; // If the property defined by `refreshTokenProp` is an object: // -----------------------------------------------------------