Skip to content

Commit 8caec3b

Browse files
add support for gcp application default auth on windows in object store (#5473)
* add support for gcp application default auth on windows in object store * syntax err * clippy --------- Co-authored-by: Itay Azolay <[email protected]>
1 parent 1553267 commit 8caec3b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

object_store/src/gcp/credential.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,11 @@ pub enum ApplicationDefaultCredentials {
393393
}
394394

395395
impl ApplicationDefaultCredentials {
396-
const CREDENTIALS_PATH: &'static str = ".config/gcloud/application_default_credentials.json";
396+
const CREDENTIALS_PATH: &'static str = if cfg!(windows) {
397+
"gcloud/application_default_credentials.json"
398+
} else {
399+
".config/gcloud/application_default_credentials.json"
400+
};
397401

398402
// Create a new application default credential in the following situations:
399403
// 1. a file is passed in and the type matches.
@@ -402,7 +406,9 @@ impl ApplicationDefaultCredentials {
402406
if let Some(path) = path {
403407
return read_credentials_file::<Self>(path).map(Some);
404408
}
405-
if let Some(home) = env::var_os("HOME") {
409+
410+
let home_var = if cfg!(windows) { "APPDATA" } else { "HOME" };
411+
if let Some(home) = env::var_os(home_var) {
406412
let path = Path::new(&home).join(Self::CREDENTIALS_PATH);
407413

408414
// It's expected for this file to not exist unless it has been explicitly configured by the user.

0 commit comments

Comments
 (0)