Skip to content

Commit d52e869

Browse files
committed
Fix non-cvd login credentials
Credential selection was interpreting missing `cvd login` crdentials as valid, and would only fall back when `cvd login` credentials were present but invalid. Bug: b/378069857 Test: cvd fetch --credential_source=gce
1 parent 2be45ad commit d52e869

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

base/cvd/cuttlefish/host/commands/cvd/fetch/fetch_cvd.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,10 @@ Result<std::unique_ptr<BuildApi>> GetBuildApi(const BuildApiFlags& flags) {
359359
StringFromEnv("HOME", ".") + "/.acloud_oauth2.dat";
360360

361361
std::unique_ptr<CredentialSource> credential_source =
362-
cvd_creds.ok() ? std::move(*cvd_creds)
363-
: CF_EXPECT(GetCredentialSourceFromFlags(
364-
*retrying_http_client, flags, oauth_filepath));
362+
cvd_creds.ok() && cvd_creds->get()
363+
? std::move(*cvd_creds)
364+
: CF_EXPECT(GetCredentialSourceFromFlags(*retrying_http_client, flags,
365+
oauth_filepath));
365366

366367
const auto cache_base_path = PerUserDir() + "/cache";
367368
return CreateBuildApi(std::move(retrying_http_client), std::move(curl),

base/cvd/cuttlefish/host/libs/web/oauth2_consent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ Result<std::unique_ptr<CredentialSource>> CredentialForScopes(
286286
return std::move(*credential);
287287
}
288288
}
289-
return {};
289+
return CF_ERR("No credentials found.");
290290
}
291291

292292
} // namespace cuttlefish

0 commit comments

Comments
 (0)