diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 0aa287ce..4b594b83 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -351,6 +351,6 @@ export function getState(name: string): string { return process.env[`STATE_${name}`] || '' } -export async function getIDToken(aud: string): Promise { +export async function getIDToken(aud = undefined): Promise { return await OidcClient.getIDToken(aud) } \ No newline at end of file diff --git a/packages/core/src/oidc-utils.ts b/packages/core/src/oidc-utils.ts index 1eff1f2c..46b0416f 100644 --- a/packages/core/src/oidc-utils.ts +++ b/packages/core/src/oidc-utils.ts @@ -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 { - - 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 { const res = await httpclient.postJson(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 { + static async getIDToken(audience: string | undefined): Promise { 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) {