Skip to content

Commit

Permalink
Move InvalidateAccessToken() from O2TS to OAuth2AccessTokenManager
Browse files Browse the repository at this point in the history
This CL is a part of moving access token management to
OAuth2AccessTokenManager.

It moves InvalidateAccessToken() to OAuth2AccessTokenManager and
cleans up InvalidateAccessTokenForClient() since it's not used.

Bug: 967598
Change-Id: I9fff699899249eae1d65d2ebfe68778fe21ead75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1670141
Commit-Queue: Julie Jeongeun Kim <jkim@igalia.com>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#671931}
  • Loading branch information
jkim-julie authored and Commit Bot committed Jun 25, 2019
1 parent 39e72a9 commit 0789a15
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
13 changes: 13 additions & 0 deletions google_apis/gaia/oauth2_access_token_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,19 @@ void OAuth2AccessTokenManager::CancelRequestsForAccount(
CancelFetchers(fetchers_to_cancel);
}

void OAuth2AccessTokenManager::InvalidateAccessToken(
const CoreAccountId& account_id,
const OAuth2TokenService::ScopeSet& scopes,
const std::string& access_token) {
// TODO(https://crbug.com/967598): Use directly
// OAuth2AccessTokenManager::InvalidateAccessTokenImpl once this fully manages
// access tokens independently of OAuth2TokenService. For now, some tests need
// to call overridden of OAuth2TokenService::InvalidateAccessTokenImpl.
token_service_->InvalidateAccessTokenImpl(
account_id, GaiaUrls::GetInstance()->oauth2_chrome_client_id(), scopes,
access_token);
}

void OAuth2AccessTokenManager::InvalidateAccessTokenImpl(
const CoreAccountId& account_id,
const std::string& client_id,
Expand Down
9 changes: 9 additions & 0 deletions google_apis/gaia/oauth2_access_token_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ class OAuth2AccessTokenManager {
// Cancels all requests related to a given |account_id|.
void CancelRequestsForAccount(const CoreAccountId& account_id);

// Mark an OAuth2 |access_token| issued for |account_id| and |scopes| as
// invalid. This should be done if the token was received from this class,
// but was not accepted by the server (e.g., the server returned
// 401 Unauthorized). The token will be removed from the cache for the given
// scopes.
void InvalidateAccessToken(const CoreAccountId& account_id,
const OAuth2TokenService::ScopeSet& scopes,
const std::string& access_token);

// Invalidates the |access_token| issued for |account_id|, |client_id| and
// |scopes|.
void InvalidateAccessTokenImpl(const CoreAccountId& account_id,
Expand Down
12 changes: 1 addition & 11 deletions google_apis/gaia/oauth2_token_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ void OAuth2TokenService::InvalidateAccessToken(
const CoreAccountId& account_id,
const ScopeSet& scopes,
const std::string& access_token) {
InvalidateAccessTokenImpl(account_id,
GaiaUrls::GetInstance()->oauth2_chrome_client_id(),
scopes, access_token);
token_manager_->InvalidateAccessToken(account_id, scopes, access_token);
}

void OAuth2TokenService::InvalidateTokenForMultilogin(
Expand All @@ -232,14 +230,6 @@ void OAuth2TokenService::InvalidateTokenForMultilogin(
delegate_->InvalidateTokenForMultilogin(failed_account);
}

void OAuth2TokenService::InvalidateAccessTokenForClient(
const CoreAccountId& account_id,
const std::string& client_id,
const ScopeSet& scopes,
const std::string& access_token) {
InvalidateAccessTokenImpl(account_id, client_id, scopes, access_token);
}

void OAuth2TokenService::InvalidateAccessTokenImpl(
const CoreAccountId& account_id,
const std::string& client_id,
Expand Down
8 changes: 1 addition & 7 deletions google_apis/gaia/oauth2_token_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,11 @@ class OAuth2TokenService : public OAuth2TokenServiceObserver {
// but was not accepted by the server (e.g., the server returned
// 401 Unauthorized). The token will be removed from the cache for the given
// scopes.
// Deprecated. It's moved to OAuth2AccessTokenManager.
void InvalidateAccessToken(const CoreAccountId& account_id,
const ScopeSet& scopes,
const std::string& access_token);

// Like |InvalidateToken| except is uses |client_id| to identity OAuth2 client
// app that issued the request instead of Chrome's default values.
void InvalidateAccessTokenForClient(const CoreAccountId& account_id,
const std::string& client_id,
const ScopeSet& scopes,
const std::string& access_token);

// Removes token from cache (if it is cached) and calls
// InvalidateTokenForMultilogin method of the delegate. This should be done if
// the token was received from this class, but was not accepted by the server
Expand Down

0 comments on commit 0789a15

Please sign in to comment.