Skip to content

Commit

Permalink
Fix non-cvd login credentials
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Databean committed Nov 11, 2024
1 parent 2be45ad commit d52e869
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions base/cvd/cuttlefish/host/commands/cvd/fetch/fetch_cvd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,10 @@ Result<std::unique_ptr<BuildApi>> GetBuildApi(const BuildApiFlags& flags) {
StringFromEnv("HOME", ".") + "/.acloud_oauth2.dat";

std::unique_ptr<CredentialSource> credential_source =
cvd_creds.ok() ? std::move(*cvd_creds)
: CF_EXPECT(GetCredentialSourceFromFlags(
*retrying_http_client, flags, oauth_filepath));
cvd_creds.ok() && cvd_creds->get()
? std::move(*cvd_creds)
: CF_EXPECT(GetCredentialSourceFromFlags(*retrying_http_client, flags,
oauth_filepath));

const auto cache_base_path = PerUserDir() + "/cache";
return CreateBuildApi(std::move(retrying_http_client), std::move(curl),
Expand Down
2 changes: 1 addition & 1 deletion base/cvd/cuttlefish/host/libs/web/oauth2_consent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ Result<std::unique_ptr<CredentialSource>> CredentialForScopes(
return std::move(*credential);
}
}
return {};
return CF_ERR("No credentials found.");
}

} // namespace cuttlefish

0 comments on commit d52e869

Please sign in to comment.