Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make refresh token request only if appKey and appSecret is present #81

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if otherwise? The rest of the function relies on fact that there is a response.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you still interested in this PR? Can you fix it or should I close?


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

Expand Down