0

[SCRIP] Add parsing access_denied errors in OATF

Add access_denied parsing in Oauth2AccessTokenFetcherImpl. These
errors were being treated as SERVICE_UNAVAILABLE before. So this cl
keeps the same behavior.

Change-Id: I8c96ea82dc467908a3c54888355fbb80900b61c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6276509
Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
Commit-Queue: Tanmoy Mollik <triploblastic@google.com>
Cr-Commit-Position: refs/heads/main@{#1423161}
This commit is contained in:
Tanmoy Mollik
2025-02-21 08:22:14 -08:00
committed by Chromium LUCI CQ
parent d731a58fb3
commit f5abf6cf92
4 changed files with 11 additions and 1 deletions

@ -95,6 +95,10 @@ OAuth2ResponseErrorToOAuth2Response(const std::string& error) {
return OAuth2AccessTokenFetcherImpl::kAdminPolicyEnforced;
}
if (error == "access_denied") {
return OAuth2AccessTokenFetcherImpl::kAccessDenied;
}
return OAuth2AccessTokenFetcherImpl::kUnknownError;
}
@ -255,6 +259,7 @@ void OAuth2AccessTokenFetcherImpl::EndGetAccessToken(
case kRateLimitExceeded:
case kInternalFailure:
case kAccessDenied:
// Transient error.
error = GoogleServiceAuthError::FromServiceUnavailable(response_str);
break;

@ -61,7 +61,8 @@ class COMPONENT_EXPORT(GOOGLE_APIS) OAuth2AccessTokenFetcherImpl
kRateLimitExceeded = 11,
kInternalFailure = 12,
kAdminPolicyEnforced = 13,
kMaxValue = kAdminPolicyEnforced,
kAccessDenied = 14,
kMaxValue = kAccessDenied,
};
OAuth2AccessTokenFetcherImpl(

@ -440,6 +440,9 @@ const OAuth2ErrorCodesTestParam kOAuth2ErrorCodesTable[] = {
{"admin_policy_enforced", net::HTTP_BAD_REQUEST,
OAuth2AccessTokenFetcherImpl::kAdminPolicyEnforced,
GoogleServiceAuthError::SCOPE_LIMITED_UNRECOVERABLE_ERROR},
{"access_denied", net::HTTP_FORBIDDEN,
OAuth2AccessTokenFetcherImpl::kAccessDenied,
GoogleServiceAuthError::SERVICE_UNAVAILABLE},
{"", net::HTTP_BAD_REQUEST,
OAuth2AccessTokenFetcherImpl::kErrorUnexpectedFormat,
GoogleServiceAuthError::SERVICE_ERROR},

@ -21003,6 +21003,7 @@ Called by update_net_error_codes.py.-->
<int value="11" label="Rate Limit Exceeded"/>
<int value="12" label="Internal Failure"/>
<int value="13" label="Admin Policy Enforced"/>
<int value="14" label="Access Denied"/>
</enum>
<enum name="OCRClientType">