Skip to content

Commit f81fd55

Browse files
fix(oauth2): do not require id_token in creds (#12867)
Only a limited number of scopes returns this field. For the rest of scopes this field is not populated, which is ok.
1 parent 953aefe commit f81fd55

2 files changed

Lines changed: 1 addition & 5 deletions

File tree

google/cloud/internal/oauth2_authorized_user_credentials.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ StatusOr<AccessToken> ParseAuthorizedUserRefreshResponse(
6868
auto access_token = nlohmann::json::parse(*payload, nullptr, false);
6969
if (access_token.is_discarded() || access_token.count("access_token") == 0 ||
7070
access_token.count("expires_in") == 0 ||
71-
access_token.count("id_token") == 0 ||
7271
access_token.count("token_type") == 0) {
7372
auto error_payload =
7473
*payload +
7574
"Could not find all required fields in response (access_token,"
76-
" id_token, expires_in, token_type) while trying to obtain an access"
75+
" expires_in, token_type) while trying to obtain an access"
7776
" token for service account credentials.";
7877
return AsStatus(status_code, error_payload);
7978
}

google/cloud/internal/oauth2_authorized_user_credentials_test.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ TEST_F(AuthorizedUserCredentialsTest, Simple) {
6262
std::string response_payload = R"""({
6363
"token_type": "Type",
6464
"access_token": "access-token-value",
65-
"id_token": "id-token-value",
6665
"expires_in": 1234
6766
})""";
6867

@@ -223,7 +222,6 @@ TEST_F(AuthorizedUserCredentialsTest,
223222
// Does not have access_token.
224223
std::string r2 = R"""({
225224
"token_type": "Type",
226-
"id_token": "id-token-value",
227225
"expires_in": 1000
228226
})""";
229227

@@ -260,7 +258,6 @@ TEST_F(AuthorizedUserCredentialsTest, ParseAuthorizedUserRefreshResponse) {
260258
std::string r1 = R"""({
261259
"token_type": "Type",
262260
"access_token": "access-token-r1",
263-
"id_token": "id-token-value",
264261
"expires_in": 1000
265262
})""";
266263

0 commit comments

Comments
 (0)