diff --git a/README.md b/README.md index e66ad85..8ab3cc2 100644 --- a/README.md +++ b/README.md @@ -348,13 +348,15 @@ autoUpdateToken: true, clientId: false, // The property name used when storing the refresh token locally refreshTokenStorage: 'aurelia_refresh_token', +// The the property from which to get the refresh token after a successful token refresh +refreshTokenProp: 'refresh_token', -// If `refresh_token` is an object: -// ------------------------------------------------------------ +// If the property defined by `refreshTokenProp` is an object: +// ----------------------------------------------------------- -// This is the property from which to get the token `{ "refresh_token": { "refreshTokenName" : '...' } }` -refreshTokenName: 'refresh_token', -// This allows the refresh token to be a further object deeper `{ "refresh_token": { "refreshTokenRoot" : { "refreshTokenName" : '...' } } }` +// This is the property from which to get the token `{ "refreshTokenProp": { "refreshTokenName" : '...' } }` +refreshTokenName: 'token', +// This allows the refresh token to be a further object deeper `{ "refreshTokenProp": { "refreshTokenRoot" : { "refreshTokenName" : '...' } } }` refreshTokenRoot: false, diff --git a/src/authentication.js b/src/authentication.js index d89761c..1a6a5f7 100644 --- a/src/authentication.js +++ b/src/authentication.js @@ -88,7 +88,7 @@ export class Authentication { } setRefreshTokenFromResponse(response) { - let refreshToken = response && response.refresh_token; + let refreshToken = response && response[this.config.refreshTokenProp]; let token; if (refreshToken) { diff --git a/src/baseConfig.js b/src/baseConfig.js index f1d6d01..3c1aded 100644 --- a/src/baseConfig.js +++ b/src/baseConfig.js @@ -88,13 +88,15 @@ export class BaseConfig { clientId: false, // The property name used when storing the refresh token locally refreshTokenStorage: 'aurelia_refresh_token', + // The the property from which to get the refresh token after a successful token refresh + refreshTokenProp: 'refresh_token', - // If `refresh_token` is an object: - // ------------------------------------------------------------ + // If the property defined by `refreshTokenProp` is an object: + // ----------------------------------------------------------- - // This is the property from which to get the token `{ "refresh_token": { "refreshTokenName" : '...' } }` - refreshTokenName: 'refresh_token', - // This allows the refresh token to be a further object deeper `{ "refresh_token": { "refreshTokenRoot" : { "refreshTokenName" : '...' } } }` + // This is the property from which to get the token `{ "refreshTokenProp": { "refreshTokenName" : '...' } }` + refreshTokenName: 'token', + // This allows the refresh token to be a further object deeper `{ "refreshTokenProp": { "refreshTokenRoot" : { "refreshTokenName" : '...' } } }` refreshTokenRoot: false,