From 76db75c6d7eca54b805b91242b639845e53f02df Mon Sep 17 00:00:00 2001 From: Tobi Date: Fri, 8 Dec 2023 18:19:39 +0100 Subject: [PATCH] docs: add client credentials flow example to readme (#640) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aranđel Šarenac <11753867+big-kahuna-burger@users.noreply.github.com> Co-authored-by: Filip Skokan --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index f4d4bbe6..fa591a72 100644 --- a/README.md +++ b/README.md @@ -246,6 +246,24 @@ This will poll in the defined interval and only resolve with a TokenSet once one will handle the defined `authorization_pending` and `slow_down` "soft" errors and continue polling but upon any other error it will reject. With tokenSet received you can throw away the handle. +### Client Credentials Grant Flow + +Client Credentials flow is for obtaining Access Tokens to use with third party APIs on behalf of your application, rather than an end-user which was the case in previous examples. + +**See the [documentation](./docs/README.md#clientgrantbody-extras) for full API details.** + +```js +const client = new issuer.Client({ + client_id: 'zELcpfANLqY7Oqas', + client_secret: 'TQV5U29k1gHibH5bx1layBo0OSAvAbRT3UYW3EWrSYBB5swxjVfWUa1BS8lqzxG/0v9wruMcrGadany3', +}); + +const tokenSet = await client.grant({ + resource: 'urn:example:third-party-api', + grant_type: 'client_credentials' +}); +``` + ## FAQ #### Semver?