Commit 3edbdd40 authored by Lambros Lambrou's avatar Lambros Lambrou Committed by Commit Bot

[remoting host] Use offline-mode for token-exchange.

This changes OAuthTokenExchanger's default mode to offline. This ensures
that a non-empty refresh token will actually be delivered to the caller
on Windows, instead of an empty string.

This CL also updates OAuthTokenExchanger so that it no longer triggers
every hour if offline-mode is used to provide a refresh token.

The effect of this CL on non-Windows platforms is that OAuthTokenGetter
will get an exchanged refresh token and will cache it in memory, using
it to get new access tokens every hour. This will avoid hitting the
TokenExchange server every hour.

Bug: 971920
Change-Id: Ic0d3e3a9ca5a5e627ae135bb005dc186ebfb4e0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1648730
Commit-Queue: Joe Downing <joedow@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#667267}
parent cb242b1a
...@@ -191,6 +191,15 @@ void OAuthTokenExchanger::OnRobotTokenResponse( ...@@ -191,6 +191,15 @@ void OAuthTokenExchanger::OnRobotTokenResponse(
return; return;
} }
// When offline mode is used, this class will return a new refresh token
// as well as an access token. It doesn't make sense to continue exchanging
// tokens every hour in this case. OAuthTokenGetterImpl remembers the new
// refresh token and uses that for fetching new access tokens every hour. So
// there's no need for further token-exchanges after the first successful one.
if (offline_mode_) {
need_token_exchange_ = false;
}
// The redirect_uri parameter is required for GetTokensFromAuthCode(), but // The redirect_uri parameter is required for GetTokensFromAuthCode(), but
// "oob" (out of band) can be used for robot accounts. // "oob" (out of band) can be used for robot accounts.
gaia::OAuthClientInfo client_info = { gaia::OAuthClientInfo client_info = {
......
...@@ -77,7 +77,7 @@ class OAuthTokenExchanger : public gaia::GaiaOAuthClient::Delegate { ...@@ -77,7 +77,7 @@ class OAuthTokenExchanger : public gaia::GaiaOAuthClient::Delegate {
base::queue<TokenCallback> pending_callbacks_; base::queue<TokenCallback> pending_callbacks_;
std::string oauth_access_token_; std::string oauth_access_token_;
bool offline_mode_ = false; bool offline_mode_ = true;
// True if the OAuth refresh token is lacking required scopes and the // True if the OAuth refresh token is lacking required scopes and the
// token-exchange service is needed to provide a new access-token. // token-exchange service is needed to provide a new access-token.
......
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