Commit 614a3d0
fix(auth): use requests transport for GCE MDS (#16480)
Fixes #16090
We were seeing errors on GCE environments, because the library would use
_http_client to communicate to the metadata server, even when mTLS is
enabled. This resulted in failures, because _http_client doesn't support
https.
This PR addresses the issue by using requests as the transport instead.
This depends on the optional `requests` dependency, but requests is
already [required by compute
engine](https://github.com/googleapis/google-cloud-python/blob/51a96200324965f071dd9542d25b907c1420b3f6/packages/google-auth/google/auth/compute_engine/_metadata.py#L27),
so there are no changes there.
I was able to reproduce and verify this test on a GCE VM
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent dea6a1b commit 614a3d0Copy full SHA for 614a3d0
3 files changed
+47-10Lines changed: 47 additions & 10 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- packages/google-auth
- google/auth
- transport
- tests
Expand file treeCollapse file tree
Open diff view settings
Collapse file
packages/google-auth/google/auth/_default.py
Copy file name to clipboardExpand all lines: packages/google-auth/google/auth/_default.py+5-9Lines changed: 5 additions & 9 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | | - |
31 | 30 | |
32 | 31 | |
33 | | - |
34 | | - |
| 32 | + |
| 33 | + |
35 | 34 | |
36 | 35 | |
37 | 36 | |
| ||
390 | 389 | |
391 | 390 | |
392 | 391 | |
393 | | - |
394 | | - |
395 | | - |
396 | | - |
397 | | - |
398 | 392 | |
399 | 393 | |
| 394 | + |
400 | 395 | |
401 | 396 | |
402 | 397 | |
| 398 | + |
403 | 399 | |
404 | 400 | |
405 | 401 | |
406 | 402 | |
407 | 403 | |
408 | | - |
| 404 | + |
409 | 405 | |
410 | 406 | |
411 | 407 | |
|
Collapse file
packages/google-auth/google/auth/transport/_http_client.py
Copy file name to clipboardExpand all lines: packages/google-auth/google/auth/transport/_http_client.py+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
94 | 94 | |
95 | 95 | |
96 | 96 | |
97 | | - |
| 97 | + |
98 | 98 | |
99 | 99 | |
100 | 100 | |
|
Collapse file
packages/google-auth/tests/test__default.py
Copy file name to clipboardExpand all lines: packages/google-auth/tests/test__default.py+41Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
890 | 890 | |
891 | 891 | |
892 | 892 | |
| 893 | + |
| 894 | + |
| 895 | + |
| 896 | + |
| 897 | + |
| 898 | + |
| 899 | + |
| 900 | + |
| 901 | + |
| 902 | + |
| 903 | + |
| 904 | + |
893 | 905 | |
894 | 906 | |
895 | 907 | |
| ||
1006 | 1018 | |
1007 | 1019 | |
1008 | 1020 | |
| 1021 | + |
| 1022 | + |
| 1023 | + |
| 1024 | + |
| 1025 | + |
| 1026 | + |
| 1027 | + |
| 1028 | + |
| 1029 | + |
| 1030 | + |
| 1031 | + |
| 1032 | + |
| 1033 | + |
| 1034 | + |
| 1035 | + |
| 1036 | + |
| 1037 | + |
| 1038 | + |
| 1039 | + |
| 1040 | + |
| 1041 | + |
| 1042 | + |
| 1043 | + |
| 1044 | + |
| 1045 | + |
| 1046 | + |
| 1047 | + |
| 1048 | + |
| 1049 | + |
1009 | 1050 | |
1010 | 1051 | |
1011 | 1052 | |
|
0 commit comments