Commit c7cd74f2 authored by jamiewalch's avatar jamiewalch Committed by Commit bot

Respect opt_scopes in getNewToken.

Without this, the downscoped token was being revoked, but the call to get a
fresh one was returning the cached non-downscoped token.

Also adds an assert to catch regressions.

BUG=b/20662147

Review URL: https://codereview.chromium.org/1123183005

Cr-Commit-Position: refs/heads/master@{#329711}
parent 9c6b54e6
......@@ -239,10 +239,16 @@ remoting.AppConnectedView.prototype.sendGoogleDriveAccessToken_ =
];
remoting.identity.getNewToken(googleDriveScopes).then(
function(/** string */ token){
base.debug.assert(token !== previousToken_);
previousToken_ = token;
sendExtensionMessage('accessToken', token);
}).catch(remoting.Error.handler(function(/** remoting.Error */ error) {
console.log('Failed to refresh access token: ' + error.toString());
}));
};
// The access token last received from getNewToken. Saved to ensure that we
// get a fresh token each time.
var previousToken_ = '';
})();
......@@ -95,7 +95,7 @@ remoting.Identity.prototype.getNewToken = function(opt_scopes) {
return this.getToken(opt_scopes).then(function(/** string */ token) {
return new Promise(function(resolve, reject) {
chrome.identity.removeCachedAuthToken({'token': token }, function() {
resolve(that.getToken());
resolve(that.getToken(opt_scopes));
});
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment