Skip to content

Commit

Permalink
Make refresh token request only if appKey and appSecret is present
Browse files Browse the repository at this point in the history
  • Loading branch information
mangatinanda committed Jul 26, 2017
1 parent 9432851 commit 7dc1cba
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 59 deletions.
98 changes: 50 additions & 48 deletions build/ringcentral.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/ringcentral.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions build/ringcentral.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/ringcentral.min.js.map

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions src/platform/Platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,14 @@ Platform.prototype._refresh = function() {
if (!this._auth.refreshToken()) throw new Error('Refresh token is missing');
if (!this._auth.refreshTokenValid()) throw new Error('Refresh token has expired');

return this._tokenRequest(Platform._tokenEndpoint, {
"grant_type": "refresh_token",
"refresh_token": this._auth.refreshToken(),
"access_token_ttl": this._auth.data().expires_in + 1,
"refresh_token_ttl": this._auth.data().refresh_token_expires_in + 1
});
if (this.appKey && this.appSecret) {
return this._tokenRequest(Platform._tokenEndpoint, {
"grant_type": "refresh_token",
"refresh_token": this._auth.refreshToken(),
"access_token_ttl": this._auth.data().expires_in + 1,
"refresh_token_ttl": this._auth.data().refresh_token_expires_in + 1
});
}

}.bind(this)).then(function(/** @type {ApiResponse} */ res) {

Expand Down

0 comments on commit 7dc1cba

Please sign in to comment.