From 8f76295675d2795818265f8eb56c7b38143c032b Mon Sep 17 00:00:00 2001 From: meilakh Date: Wed, 11 Oct 2023 13:56:44 +0000 Subject: [PATCH] micro: remove the requirement to have id_token in response. Only a limited number of scopes returns this field. For the rest of scopes this field is not populated, which is ok. --- google/cloud/internal/oauth2_authorized_user_credentials.cc | 3 +-- .../cloud/internal/oauth2_authorized_user_credentials_test.cc | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/google/cloud/internal/oauth2_authorized_user_credentials.cc b/google/cloud/internal/oauth2_authorized_user_credentials.cc index b445a2d33245b..bfa046a520b68 100644 --- a/google/cloud/internal/oauth2_authorized_user_credentials.cc +++ b/google/cloud/internal/oauth2_authorized_user_credentials.cc @@ -68,12 +68,11 @@ StatusOr ParseAuthorizedUserRefreshResponse( auto access_token = nlohmann::json::parse(*payload, nullptr, false); if (access_token.is_discarded() || access_token.count("access_token") == 0 || access_token.count("expires_in") == 0 || - access_token.count("id_token") == 0 || access_token.count("token_type") == 0) { auto error_payload = *payload + "Could not find all required fields in response (access_token," - " id_token, expires_in, token_type) while trying to obtain an access" + " expires_in, token_type) while trying to obtain an access" " token for service account credentials."; return AsStatus(status_code, error_payload); } diff --git a/google/cloud/internal/oauth2_authorized_user_credentials_test.cc b/google/cloud/internal/oauth2_authorized_user_credentials_test.cc index 5399508873b48..1d1b5d5eb1402 100644 --- a/google/cloud/internal/oauth2_authorized_user_credentials_test.cc +++ b/google/cloud/internal/oauth2_authorized_user_credentials_test.cc @@ -62,7 +62,6 @@ TEST_F(AuthorizedUserCredentialsTest, Simple) { std::string response_payload = R"""({ "token_type": "Type", "access_token": "access-token-value", - "id_token": "id-token-value", "expires_in": 1234 })"""; @@ -223,7 +222,6 @@ TEST_F(AuthorizedUserCredentialsTest, // Does not have access_token. std::string r2 = R"""({ "token_type": "Type", - "id_token": "id-token-value", "expires_in": 1000 })"""; @@ -260,7 +258,6 @@ TEST_F(AuthorizedUserCredentialsTest, ParseAuthorizedUserRefreshResponse) { std::string r1 = R"""({ "token_type": "Type", "access_token": "access-token-r1", - "id_token": "id-token-value", "expires_in": 1000 })""";