2021-07-27 09:47:27 +05:30
<h2>@actions/oidc -client</h2>
2021-07-01 08:11:28 +05:30
<h3>Usage</h3>
2021-07-28 15:54:05 +05:30
You can use this package to interact with the GitHub OIDC provider and get a JWT ID token which would help to get access token from third party cloud providers.
2021-07-01 08:11:28 +05:30
<h3>Get the ID token</h3>
Method Name: getIDToken
<h3>Inputs</h3>
2021-07-26 15:50:36 +05:30
audience : optional
2021-07-01 08:11:28 +05:30
2021-07-28 15:54:05 +05:30
<h3>Outputs</h3>
A [JWT ](https://jwt.io/ ) ID Token
2021-07-28 14:01:17 +05:30
You can use this [template ](https://github.com/actions/typescript-action ) to use the package.
2021-07-01 08:11:28 +05:30
<h3>Example:</h3>
2021-07-28 14:01:17 +05:30
main.ts
2021-07-01 08:11:28 +05:30
```
const core = require('@actions/core');
const id = require('@actions/oidc-client')
2021-07-28 15:54:05 +05:30
async function getIDTokenAction(): Promise<void> {
2021-07-28 14:01:17 +05:30
let aud = ''
const audience = core.getInput('audience', {required: false})
if (audience !== undefined)
aud = `${audience}`
const id_token = await id.getIDToken(aud)
2021-07-01 08:11:28 +05:30
const val = `ID token is ${id_token}`
core.setOutput('id_token', id_token);
}
2021-07-28 15:54:05 +05:30
getIDTokenAction()
2021-07-01 08:11:28 +05:30
```
2021-07-28 14:01:17 +05:30
actions.yml
```
name: 'GetIDToken'
description: 'Get ID token from Github OIDC provider'
inputs:
audience:
description: 'Audience for which the ID token is intended for'
required: false
outputs:
id_token:
description: 'ID token obtained from OIDC provider'
runs:
using: 'node12'
main: 'dist/index.js'
```