1
0
Fork 0
toolkit/packages/oidc-client/README.md

54 lines
1.1 KiB
Markdown
Raw Normal View History

2021-07-27 04:17:27 +00:00
<h2>@actions/oidc-client</h2>
2021-07-01 02:41:28 +00:00
<h3>Usage</h3>
You can use this package to interact with the github oidc provider.
<h3>Get the ID token</h3>
Method Name: getIDToken
<h3>Inputs</h3>
2021-07-26 10:20:36 +00:00
audience : optional
2021-07-01 02:41:28 +00:00
2021-07-28 08:31:17 +00:00
You can use this [template](https://github.com/actions/typescript-action) to use the package.
2021-07-01 02:41:28 +00:00
<h3>Example:</h3>
2021-07-28 08:31:17 +00:00
main.ts
2021-07-01 02:41:28 +00:00
```
const core = require('@actions/core');
const id = require('@actions/oidc-client')
2021-07-28 08:31:17 +00:00
async function getID(): Promise<void> {
let aud = ''
const audience = core.getInput('audience', {required: false})
if (audience !== undefined)
aud = `${audience}`
const id_token = await id.getIDToken(aud)
2021-07-01 02:41:28 +00:00
const val = `ID token is ${id_token}`
core.setOutput('id_token', id_token);
}
getID()
```
2021-07-28 08:31:17 +00:00
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'
```