Commit 383c982
feat: honor
Currently, `google.auth.default()` always attempts to authenticate using
the Google Compute Engine (GCE) metadata service as a fallback. There is
no easy way to prevent this behavior, leading to unnecessary delays and
unhelpful exceptions, particularly in cases where GCE-based
authentication is pointless or undesired.
This pull request introduces a `NO_GCE_CHECK` environment variable,
allowing users to explicitly skip GCE metadata service authentication.
This implementation mirrors `NO_GCE_CHECK` in
[googleapis/google-auth-library-java](https://github.com/googleapis/google-auth-library-java/blob/f154edb3d8503d29f0020b6904dfa40e034ded93/README.md?plain=1#L106-L119):
> _The following are searched (in order) to find the Application Default
Credentials:_
>
> [...]
>
> 5. Google Compute Engine built-in credentials
> - Skip this check by setting the environment variable
`NO_GCE_CHECK=true`
> [!NOTE]
> Other clouds also provide similar environment variables, such as
`AWS_EC2_METADATA_DISABLED` on AWS.
This change is also tangentially related to the following pull requests:
- #1488
- #1481
---------
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Chalmer Lowe <chalmerlowe@google.com>NO_GCE_CHECK environment variable (#1610)1 parent e431f20 commit 383c982
File tree
3 files changed
+27
-0
lines changed- google/auth
- compute_engine
- tests/compute_engine
3 files changed
+27
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
| |||
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
119 | 126 | | |
120 | 127 | | |
121 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
111 | 125 | | |
112 | 126 | | |
113 | 127 | | |
| |||
0 commit comments