OAuth

Frends.OAuth.CreateJWTToken / 1.4.0

Summary

Builds a JSON Web Token from the claims, lifetime and audience you specify and signs it with a certificate or private key, producing a credential rather than validating one.

Typical use — authenticating to services that expect a self-signed assertion instead of a shared secret; the signing key belongs in an environment variable, never in the Process

Details

Frends version
5.5 and newer
Agent
Crossplatform
Target framework
net6.0

Input parameters.

Name Type Default Example Description
Issuer String Issuer Issuer

Value for "iss" (Issuer) Claim.

Audience String Audience Audience

Value for "aud" (Audience) Claim.

Expires Nullable<DateTime> DateTime.Now.AddDays(7) DateTime.Now.AddDays(7)

Value for "exp" (Expiration Time) Claim.

NotBefore Nullable<DateTime> DateTime.Now.AddDays(1) DateTime.Now.AddDays(1)

Value for "nbf" (Not Before) Claim. Set to null if you don't want to include it.

X509Thumbprint String X5T X5T

Value for "x5t" (X.509 Certificate SHA-1 Thumbprint) Header.

PrivateKeySecret String -----BEGIN RSA PRIVATE KEY-----TheKey-----END RSA PRIVATE KEY-----

Private key for signing. The key should be in PEM format for asymmetric algorithms. If symmetric algorithms is used, key can be any string.

SigningAlgorithm SigningAlgorithm RS256 RS256

Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.

Possible values:

  • RS256: Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.

  • RS384: Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.

  • RS512: Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.

  • HS256: Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.

  • HS384: Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.

  • HS512: Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.

  • ES256: Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.

  • ES384: Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.

  • ES512: Algorithm used for signing, default is RS256. HS256/HS384/HS512 are symmetric algorithms, RS256/RS384/RS512 asymmetric.

Claims JwtClaim[] Name, Value

Optional value(s) for "sub" (Subject) Claim. Multiple claims with same keys/names can be added.

CustomHeaders CustomHeader[] kid, fsdjfosabgpasbgbbs

Optional custom headers.

An unhandled error has occurred. Reload 🗙