You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
-24Lines changed: 0 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -322,30 +322,6 @@ regardless of the authentication mechanism.
322
322
"token_format" is "id_token".
323
323
324
324
325
-
## Python Usage Note
326
-
327
-
When using Workload Identity Federation with Python libraries (e.g., `google-auth`), you may encounter errors when trying to refresh credentials to get an ID token. This is because the Google Auth library requires scopes to be set when refreshing credentials for impersonation.
328
-
329
-
If you need an ID token in Python, you have two options:
330
-
331
-
1. **Use the `token_format` parameter** (recommended): Generate the ID token directly with this action and use it as an environment variable in your Python code.
332
-
333
-
2. **Add scopes before refreshing**: If using default credentials, add the required scopes before refreshing:
334
-
335
-
```python
336
-
from google.auth import default
337
-
from google.auth.transport.requests import Request
For more details and examples, see the [Troubleshooting guide](docs/TROUBLESHOOTING.md#cannot-refresh-credentials-to-retrieve-an-id-token) and [Examples](docs/EXAMPLES.md#using-default-credentials-with-scopes-in-python).
Copy file name to clipboardExpand all lines: docs/TROUBLESHOOTING.md
+11-3Lines changed: 11 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,8 @@ tool like `jq`:
230
230
cat credentials.json | jq -r tostring
231
231
```
232
232
233
+
<a name="cannot-refresh"></a>
234
+
233
235
## Cannot refresh credentials to retrieve an ID token
234
236
235
237
If you get an error like:
@@ -238,7 +240,9 @@ If you get an error like:
238
240
google.auth.exceptions.RefreshError: ('Unable to acquire impersonated credentials', '{"error": {"code": 400, "message": "Request contains an invalid argument.", "status": "INVALID_ARGUMENT"}}')
239
241
```
240
242
241
-
when trying to refresh credentials in Python code to get an ID token, this is usually because the credentials are missing required scopes. The Google Auth library requires scopes to be set when refreshing credentials for impersonation.
243
+
when trying to refresh credentials in Python code to get an ID token, this is
244
+
usually because the credentials are missing required scopes. The Google Auth
245
+
library requires scopes to be set when refreshing credentials for impersonation.
242
246
243
247
To fix this issue, add the required scopes before refreshing:
244
248
@@ -247,16 +251,19 @@ from google.auth import default
247
251
from google.auth.transport.requests import Request
0 commit comments