Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
feat(refresh_token): Add a configuration option for the refresh token…
Browse files Browse the repository at this point in the history
… requests

Add a configuration option for the refresh token requests
  • Loading branch information
doktordirk committed Sep 26, 2016
2 parents a583f81 + 1860d16 commit a48518e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/refresh_token.md
Expand Up @@ -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:
// -----------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions src/authService.js
Expand Up @@ -322,12 +322,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)
Expand Down
2 changes: 2 additions & 0 deletions src/baseConfig.js
Expand Up @@ -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:
// -----------------------------------------------------------
Expand Down

0 comments on commit a48518e

Please sign in to comment.