# CreateJWTToken

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.OAuth>

{% tabs %}
{% tab title="Parameter: Input" %}

| Name                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Issuer : `String`                     | <p>Value for "iss" (Issuer) Claim.</p><p><br>Default: <code>Issuer</code><br>Example: <code>Issuer</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Audience : `String`                   | <p>Value for "aud" (Audience) Claim.</p><p><br>Default: <code>Audience</code><br>Example: <code>Audience</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| Expires : `Nullable<DateTime>`        | <p>Value for "exp" (Expiration Time) Claim.</p><p><br>Default: <code>DateTime.Now\.AddDays(7)</code><br>Example: <code>DateTime.Now\.AddDays(7)</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| NotBefore : `Nullable<DateTime>`      | <p>Value for "nbf" (Not Before) Claim. Set to null if you don't want to include it.</p><p><br>Default: <code>DateTime.Now\.AddDays(1)</code><br>Example: <code>DateTime.Now\.AddDays(1)</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| X509Thumbprint : `String`             | <p>Value for "x5t" (X.509 Certificate SHA-1 Thumbprint) Header.</p><p><br>Default: <code>X5T</code><br>Example: <code>X5T</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| 🗝PrivateKey : `String`               | <p>Private key for signing. The key should be in PEM format for asymmetric algorithms. If symmetric algorithms is used, key can be any string.</p><p><br>Default: <code>-</code><br>Example: <code>-----BEGIN RSA PRIVATE KEY-----TheKey-----END RSA PRIVATE KEY-----</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| SigningAlgorithm : `SigningAlgorithm` | <p>Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.</p><p>Possible values:</p><ul><li><code>RS256</code>:</li></ul><p>Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.</p><ul><li><code>RS384</code>:</li></ul><p>Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.</p><ul><li><code>RS512</code>:</li></ul><p>Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.</p><ul><li><code>HS256</code>:</li></ul><p>Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.</p><ul><li><code>HS384</code>:</li></ul><p>Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.</p><ul><li><code>HS512</code>:</li></ul><p>Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.</p><ul><li><code>ES256</code>:</li></ul><p>Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.</p><ul><li><code>ES384</code>:</li></ul><p>Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.</p><ul><li><code>ES512</code>:</li></ul><p>Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.</p><p><br>Default: <code>0</code><br>Example: <code>RS256</code></p> |
| Claims : `JwtClaim[]`                 | <p>Optional value(s) for "sub" (Subject) Claim. Multiple claims with same keys/names can be added.</p><p><br>Default: <code>-</code><br>Example: <code>Name, Value</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| CustomHeaders : `CustomHeader[]`      | <p>Optional custom headers.</p><p><br>Default: <code>-</code><br>Example: <code>kid, fsdjfosabgpasbgbbs</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| {% endtab %}                          |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

{% tab title="Result: TokenResult" %}

| Name             | Description                                                                                                                                                                                                                                                 |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Token : `String` | <p>Token.<br>Example: <code>"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJOYW1lIjoiQ2xhaW1lciIsIm5iZiI6sTY1NjQ5OTk3NiwiZXhwIjoxNjU2NTAwMDMyLCJpYXQiOjE2NTY0OTk5NzYsImlzckI6ImZyZW5kcyIsImF1ZCI6ImF1ZCJ9.qImoi\_fSi2BL4aoxIvvaGUVoM7usX40Mrdodh4yD8BY"</code></p> |
| {% endtab %}     |                                                                                                                                                                                                                                                             |

{% tab title="Changelog" %}

## Changelog

### \[1.4.0] - 2025-11-18

#### Fixes

* Fix disposing of a private key issue when a task is reused in a process.

### \[1.3.0] - 2024-08-21

#### Added

* Support for new IdentityModel-version.

### \[1.2.0] - 2023-12-21

#### Added

* Support for ES256, ES384 and ES512 encryption algorithms.

### \[1.1.0] - 2023-12-04

#### Added

* Not Before claim set to optional. Added feature to add customer headers to JWT header.

### \[1.0.0] - 2022-06-29

#### Added

* Initial implementation
  {% endtab %}
  {% endtabs %}
