mirror of https://github.com/actions/toolkit
Updated Readme
parent
58dfa1c4ac
commit
330dc0b5b8
|
@ -12,15 +12,22 @@ Method Name: getIDToken
|
|||
|
||||
audience : optional
|
||||
|
||||
You can use this [template](https://github.com/actions/typescript-action) to use the package.
|
||||
<h3>Example:</h3>
|
||||
|
||||
main.ts
|
||||
```
|
||||
const core = require('@actions/core');
|
||||
const id = require('@actions/oidc-client')
|
||||
|
||||
|
||||
async function getID(){
|
||||
const id_token = await id.getIDToken('client-id', 'client-secret')
|
||||
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)
|
||||
const val = `ID token is ${id_token}`
|
||||
core.setOutput('id_token', id_token);
|
||||
|
||||
|
@ -28,3 +35,19 @@ async function getID(){
|
|||
|
||||
getID()
|
||||
```
|
||||
|
||||
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'
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue