Skip to content

Commit

Permalink
fix(auth): add client_id to the refresh request (#2350)
Browse files Browse the repository at this point in the history
  • Loading branch information
alain-charles committed Sep 17, 2020
1 parent 61af463 commit 10b01fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/framework/auth/strategies/oauth2/oauth2-strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,10 @@ describe('oauth2-auth-strategy', () => {
});
});
it('handle refresh token with NO client auth', (done: DoneFn) => {
strategy.setOptions(basicOptions);
strategy.setOptions({
... basicOptions,
clientId: 'clientId',
});

strategy.refreshToken(successToken)
.subscribe((result: NbAuthResult) => {
Expand All @@ -636,7 +639,8 @@ describe('oauth2-auth-strategy', () => {
&& req.headers.get('Content-Type') === 'application/x-www-form-urlencoded'
&& decodeURIComponent(params['grant_type']) === NbOAuth2GrantType.REFRESH_TOKEN
&& decodeURIComponent(params['refresh_token']) === successToken.getRefreshToken()
&& decodeURIComponent(params['scope']) === 'read')
&& decodeURIComponent(params['scope']) === 'read'
&& decodeURIComponent(params['client_id']) === 'clientId')
},
)
.flush(tokenSuccessResponse);
Expand Down
1 change: 1 addition & 0 deletions src/framework/auth/strategies/oauth2/oauth2-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export class NbOAuth2AuthStrategy extends NbAuthStrategy {
grant_type: this.getOption('refresh.grantType'),
refresh_token: token.getRefreshToken(),
scope: this.getOption('refresh.scope'),
client_id: this.getOption('clientId'),
};
return this.urlEncodeParameters(this.cleanParams(this.addCredentialsToParams(params)));
}
Expand Down

0 comments on commit 10b01fa

Please sign in to comment.