mirror of https://github.com/actions/toolkit
audience can be undefined
parent
1162975200
commit
1c03cd3284
|
@ -351,6 +351,6 @@ export function getState(name: string): string {
|
|||
return process.env[`STATE_${name}`] || ''
|
||||
}
|
||||
|
||||
export async function getIDToken(aud: string): Promise<string> {
|
||||
export async function getIDToken(aud = undefined): Promise<string> {
|
||||
return await OidcClient.getIDToken(aud)
|
||||
}
|
|
@ -45,12 +45,7 @@ export class OidcClient {
|
|||
return runtimeUrl + '?api-version=' + OidcClient.getApiVersion()
|
||||
}
|
||||
|
||||
private static async postCall(httpclient: actions_http_client.HttpClient, id_token_url: string, audience: string): Promise<string> {
|
||||
|
||||
const data: TokenRequest = { aud: audience }
|
||||
|
||||
debug(`audience is ${!!audience ? audience : 'not defined'}`)
|
||||
|
||||
private static async postCall(httpclient: actions_http_client.HttpClient, id_token_url: string, data: TokenRequest): Promise<string> {
|
||||
const res = await httpclient.postJson<TokenResponse>(id_token_url,data).catch((error) => {
|
||||
throw new Error(
|
||||
`Failed to get ID Token. \n
|
||||
|
@ -67,7 +62,7 @@ export class OidcClient {
|
|||
|
||||
}
|
||||
|
||||
static async getIDToken(audience: string): Promise<string> {
|
||||
static async getIDToken(audience: string | undefined): Promise<string> {
|
||||
try {
|
||||
const httpclient = OidcClient.createHttpClient()
|
||||
|
||||
|
@ -76,7 +71,11 @@ export class OidcClient {
|
|||
|
||||
debug(`ID token url is ${id_token_url}`)
|
||||
|
||||
const id_token = await OidcClient.postCall(httpclient ,id_token_url, audience)
|
||||
const data: TokenRequest = { aud: audience }
|
||||
|
||||
debug(`audience is ${!!audience ? audience : 'not defined'}`)
|
||||
|
||||
const id_token = await OidcClient.postCall(httpclient ,id_token_url, data)
|
||||
setSecret(id_token)
|
||||
return id_token
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue