#include "google_apis/gaia/gaia_oauth_client.h"
#include <memory>
#include <utility>
#include "base/check.h"
#include "base/check_op.h"
#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "base/values.h"
#include "google_apis/credentials_mode.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/gaia_urls.h"
#include "net/base/backoff_entry.h"
#include "net/base/load_flags.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "url/gurl.h"
namespace {
const char kAccessTokenValue[] = …;
const char kRefreshTokenValue[] = …;
const char kExpiresInValue[] = …;
}
namespace gaia {
class GaiaOAuthClient::Core
: public base::RefCountedThreadSafe<GaiaOAuthClient::Core> { … };
void GaiaOAuthClient::Core::GetTokensFromAuthCode(
const OAuthClientInfo& oauth_client_info,
const std::string& auth_code,
int max_retries,
GaiaOAuthClient::Delegate* delegate) { … }
void GaiaOAuthClient::Core::RefreshToken(
const OAuthClientInfo& oauth_client_info,
const std::string& refresh_token,
const std::vector<std::string>& scopes,
int max_retries,
GaiaOAuthClient::Delegate* delegate) { … }
void GaiaOAuthClient::Core::GetUserEmail(const std::string& oauth_access_token,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::Core::GetUserId(const std::string& oauth_access_token,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::Core::GetUserInfo(const std::string& oauth_access_token,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::Core::GetUserInfoImpl(
RequestType type,
const std::string& oauth_access_token,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::Core::GetTokenInfo(const std::string& qualifier,
const std::string& query,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::Core::GetAccountCapabilities(
const std::string& oauth_access_token,
const std::vector<std::string>& capabilities_names,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::Core::MakeRequest(
RequestType type,
const GURL& url,
std::string post_body,
std::string authorization_header,
std::string http_method_override_header,
int max_retries,
GaiaOAuthClient::Delegate* delegate,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) { … }
void GaiaOAuthClient::Core::SendRequest() { … }
void GaiaOAuthClient::Core::SendRequestImpl() { … }
void GaiaOAuthClient::Core::OnURLLoadComplete(
std::unique_ptr<std::string> body) { … }
void GaiaOAuthClient::Core::HandleResponse(std::unique_ptr<std::string> body,
bool* should_retry_request) { … }
GaiaOAuthClient::GaiaOAuthClient(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) { … }
GaiaOAuthClient::~GaiaOAuthClient() { … }
void GaiaOAuthClient::GetTokensFromAuthCode(
const OAuthClientInfo& oauth_client_info,
const std::string& auth_code,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::RefreshToken(const OAuthClientInfo& oauth_client_info,
const std::string& refresh_token,
const std::vector<std::string>& scopes,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::GetUserEmail(const std::string& access_token,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::GetUserId(const std::string& access_token,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::GetUserInfo(const std::string& access_token,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::GetTokenInfo(const std::string& access_token,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::GetTokenHandleInfo(const std::string& token_handle,
int max_retries,
Delegate* delegate) { … }
void GaiaOAuthClient::GetAccountCapabilities(
const std::string& oauth_access_token,
const std::vector<std::string>& capabilities_names,
int max_retries,
Delegate* delegate) { … }
}