Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions packages/core/src/oidc-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,23 @@ export class OidcClient {
const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN']
if (!token) {
throw new Error(
'Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable'
'Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable. Ensure your workflow has:\n' +
' permissions:\n' +
' id-token: write'
)
Comment on lines 31 to 35
}
setSecret(token)
return token
}

private static getIDTokenUrl(): string {
const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL']
if (!runtimeUrl) {
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable')
throw new Error(
'Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable. Ensure your workflow has:\n' +
' permissions:\n' +
' id-token: write'
)
Comment on lines 43 to +48
}
return runtimeUrl
}
Expand All @@ -58,7 +65,10 @@ export class OidcClient {

const id_token = res.result?.value
if (!id_token) {
throw new Error('Response json body do not have ID Token field')
throw new Error(
`Response json body does not have ID Token field (HTTP ${res.statusCode}). ` +
'Verify that the audience is correct and that the token service URL is reachable.'
)
Comment on lines +68 to +71
}
return id_token
}
Expand Down