Skip to content

Commit 015a7de

Browse files
committed
oidc-exchange: reflow
Signed-off-by: William Woodruff <[email protected]>
1 parent 4cec0fc commit 015a7de

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

oidc-exchange.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@
1010

1111
_GITHUB_STEP_SUMMARY = Path(os.getenv("GITHUB_STEP_SUMMARY"))
1212

13+
_TOKEN_RETRIEVAL_FAILED_MESSAGE = dedent(
14+
"""
15+
OIDC token retrieval failed: {identity_error}
16+
17+
This generally indicates a workflow configuration error, such as insufficient
18+
permissions. Make sure that your workflow has `id-token: write` configured
19+
at either the workflow or job level, e.g.:
20+
21+
```yaml
22+
permissions:
23+
id-token: write
24+
```
25+
"""
26+
)
27+
1328

1429
def die(msg: str) -> NoReturn:
1530
with _GITHUB_STEP_SUMMARY.open("a") as io:
@@ -75,23 +90,8 @@ def get_normalized_input(name: str) -> str | None:
7590

7691
try:
7792
oidc_token = id.detect_credential(audience=oidc_audience)
78-
except id.IdentityError as exc:
79-
die(
80-
dedent(
81-
f"""
82-
OIDC token retrieval failed: {exc}
83-
84-
This generally indicates a workflow configuration error, such as insufficient
85-
permissions. Make sure that your workflow has `id-token: write` configured
86-
at either the workflow or job level, e.g.:
87-
88-
```yaml
89-
permissions:
90-
id-token: write
91-
```
92-
"""
93-
)
94-
)
93+
except id.IdentityError as identity_error:
94+
die(_TOKEN_RETRIEVAL_FAILED_MESSAGE.format(identity_error=identity_error))
9595

9696
# Now we can do the actual token exchange.
9797
mint_token_resp = requests.post(

0 commit comments

Comments
 (0)