mirror of https://github.com/actions/toolkit
Comments Resolved
parent
bdacfc4c65
commit
1322acbcca
|
@ -14,18 +14,8 @@ export function getIDTokenUrl(): string {
|
||||||
return runtimeUrl
|
return runtimeUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWorkFlowRunId(): string {
|
|
||||||
const workFlowRunId = process.env['GITHUB_RUN_ID']
|
|
||||||
if (!workFlowRunId) {
|
|
||||||
throw new Error('Unable to get GITHUB_RUN_ID env variable')
|
|
||||||
}
|
|
||||||
return workFlowRunId
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getIDTokenFromEnv(): string {
|
export function getIDTokenFromEnv(): string {
|
||||||
const tokenId = process.env['OIDC_TOKEN_ID'] //Need to check the exact env var name
|
const tokenId = process.env['OIDC_TOKEN_ID'] //Need to check the exact env var name
|
||||||
if(!tokenId) {
|
|
||||||
throw new Error('Unable to get OIDC_TOKEN_ID env variable')
|
|
||||||
}
|
|
||||||
return tokenId
|
return tokenId
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,7 @@ import {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function getApiVersion(): string {
|
export function getApiVersion(): string {
|
||||||
return '1.0'
|
return '2.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,11 @@ export async function getIDToken(audience: string): Promise<string> {
|
||||||
}
|
}
|
||||||
core.debug(`Httpclient created ${httpclient} `) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
|
core.debug(`Httpclient created ${httpclient} `) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
|
||||||
|
|
||||||
|
var additionalHeaders = {[httpclient.Headers.ContentType]: httpclient.MediaTypes.ApplicationJson}
|
||||||
|
|
||||||
const response = await httpclient.post(id_tokne_url, audience)
|
var data : String = new String('id_token_aud:')
|
||||||
|
data = data.concat(audience)
|
||||||
|
const response = await httpclient.post(id_tokne_url, data, additionalHeaders)
|
||||||
|
|
||||||
|
|
||||||
if (!isSuccessStatusCode(response.message.statusCode)){
|
if (!isSuccessStatusCode(response.message.statusCode)){
|
||||||
|
@ -53,7 +56,7 @@ export async function getIDToken(audience: string): Promise<string> {
|
||||||
|
|
||||||
const body: string = await response.readBody()
|
const body: string = await response.readBody()
|
||||||
const val = JSON.parse(body)
|
const val = JSON.parse(body)
|
||||||
id_token = val['id_token']
|
id_token = val['value']
|
||||||
|
|
||||||
if (id_token == undefined) {
|
if (id_token == undefined) {
|
||||||
throw new Error(`Not able to fetch the ID token`)
|
throw new Error(`Not able to fetch the ID token`)
|
||||||
|
|
Loading…
Reference in New Issue