Share via


JwtPayload.AddClaims Method

Adds a number of Claim objects to the JwtPayload as JSON in the form of { name, value } pairs.

Namespace:  System.IdentityModel.Tokens
Assembly:  System.IdentityModel.Tokens.Jwt (in System.IdentityModel.Tokens.Jwt.dll)

Syntax

'Declaration
Public Sub AddClaims ( _
    claims As IEnumerable(Of Claim) _
)
public void AddClaims(
    IEnumerable<Claim> claims
)
public:
void AddClaims(
    IEnumerable<Claim^>^ claims
)
member AddClaims : 
        claims:IEnumerable<Claim> -> unit
public function AddClaims(
    claims : IEnumerable<Claim>
)

Parameters

  • claims
    Type: System.Collections.Generic.IEnumerable<Claim>

    For each Claim, a JSON pair in the form of { 'Claim.Type', 'Claim.Value' } is added. If duplicate claims are found then a { 'Claim.Type', List<object> } will be created to contain the duplicate values.

Exceptions

Exception Condition
ArgumentNullException

claims is null.

Remarks

Each Claim added will have Type translated according to the mapping found in OutboundClaimTypeMap. Adding and removing to OutboundClaimTypeMap will affect the name component of the JSON claim.

Any Claim in the IEnumerable<T> that is null will be ignored.

.NET Framework Security

See Also

Reference

JwtPayload Class

System.IdentityModel.Tokens Namespace