Class OpenIddictMessage
- Namespace
- OpenIddict.Abstractions
- Assembly
- OpenIddict.Abstractions.dll
Represents an abstract OpenIddict message.
[JsonConverter(typeof(OpenIddictConverter))]
public class OpenIddictMessage
- Inheritance
-
OpenIddictMessage
- Derived
- Inherited Members
Remarks
Security notice: developers instantiating this type are responsible for ensuring that the imported parameters are safe and won't cause the resulting message to grow abnormally, which may result in an excessive memory consumption and a potential denial of service.
Constructors
OpenIddictMessage()
Initializes a new OpenIddict message.
public OpenIddictMessage()
OpenIddictMessage(IEnumerable<KeyValuePair<string, StringValues>>)
Initializes a new OpenIddict message.
public OpenIddictMessage(IEnumerable<KeyValuePair<string, StringValues>> parameters)
Parameters
parameters
IEnumerable<KeyValuePair<string, StringValues>>The message parameters.
Remarks
Parameters with a null or empty key are always ignored.
OpenIddictMessage(IEnumerable<KeyValuePair<string, OpenIddictParameter>>)
Initializes a new OpenIddict message.
public OpenIddictMessage(IEnumerable<KeyValuePair<string, OpenIddictParameter>> parameters)
Parameters
parameters
IEnumerable<KeyValuePair<string, OpenIddictParameter>>The message parameters.
Remarks
Parameters with a null or empty key are always ignored.
OpenIddictMessage(IEnumerable<KeyValuePair<string, string?[]?>>)
Initializes a new OpenIddict message.
public OpenIddictMessage(IEnumerable<KeyValuePair<string, string?[]?>> parameters)
Parameters
parameters
IEnumerable<KeyValuePair<string, string[]>>The message parameters.
Remarks
Parameters with a null or empty key are always ignored.
OpenIddictMessage(IEnumerable<KeyValuePair<string, string?>>)
Initializes a new OpenIddict message.
public OpenIddictMessage(IEnumerable<KeyValuePair<string, string?>> parameters)
Parameters
parameters
IEnumerable<KeyValuePair<string, string>>The message parameters.
Remarks
Parameters with a null or empty key are always ignored.
OpenIddictMessage(NameValueCollection)
Initializes a new OpenIddict message.
public OpenIddictMessage(NameValueCollection parameters)
Parameters
parameters
NameValueCollectionThe message parameters.
Remarks
Parameters with a null or empty key are always ignored.
OpenIddictMessage(JsonElement)
Initializes a new OpenIddict message.
public OpenIddictMessage(JsonElement parameters)
Parameters
parameters
JsonElementThe message parameters.
Remarks
Parameters with a null or empty key are always ignored.
OpenIddictMessage(JsonObject)
Initializes a new OpenIddict message.
public OpenIddictMessage(JsonObject parameters)
Parameters
parameters
JsonObjectThe message parameters.
Remarks
Parameters with a null or empty key are always ignored.
Properties
Count
Gets the number of parameters contained in the current message.
public int Count { get; }
Property Value
this[string]
Gets or sets a parameter.
public OpenIddictParameter? this[string name] { get; set; }
Parameters
name
stringThe parameter name.
Property Value
- OpenIddictParameter?
The parameter value.
Parameters
Gets the dictionary containing the parameters.
protected Dictionary<string, OpenIddictParameter> Parameters { get; }
Property Value
Methods
AddParameter(string, OpenIddictParameter)
Adds a parameter. Note: an exception is thrown if a parameter with the same name was already added.
public OpenIddictMessage AddParameter(string name, OpenIddictParameter value)
Parameters
name
stringThe parameter name.
value
OpenIddictParameterThe parameter value.
Returns
- OpenIddictMessage
The current instance, which allows chaining calls.
GetParameter(string)
Gets the value corresponding to a given parameter.
public OpenIddictParameter? GetParameter(string name)
Parameters
name
stringThe parameter name.
Returns
- OpenIddictParameter?
The parameter value, or null if it cannot be found.
GetParameters()
Gets all the parameters associated with this instance.
public IReadOnlyDictionary<string, OpenIddictParameter> GetParameters()
Returns
- IReadOnlyDictionary<string, OpenIddictParameter>
The parameters associated with this instance.
HasParameter(string)
Determines whether the current message contains the specified parameter.
public bool HasParameter(string name)
Parameters
name
stringThe parameter name.
Returns
RemoveParameter(string)
Removes a parameter.
public OpenIddictMessage RemoveParameter(string name)
Parameters
name
stringThe parameter name.
Returns
- OpenIddictMessage
The current instance, which allows chaining calls.
SetParameter(string, OpenIddictParameter?)
Adds, replaces or removes a parameter. Note: this method automatically removes empty parameters.
public OpenIddictMessage SetParameter(string name, OpenIddictParameter? value)
Parameters
name
stringThe parameter name.
value
OpenIddictParameter?The parameter value.
Returns
- OpenIddictMessage
The current instance, which allows chaining calls.
ToString()
Returns a string representation of the current instance that can be used in logs. Note: sensitive parameters like client secrets are automatically removed for security reasons.
public override string ToString()
Returns
- string
The indented JSON representation corresponding to this message.
TryGetParameter(string, out OpenIddictParameter)
Tries to get the value corresponding to a given parameter.
public bool TryGetParameter(string name, out OpenIddictParameter value)
Parameters
name
stringThe parameter name.
value
OpenIddictParameterThe parameter value.
Returns
WriteTo(Utf8JsonWriter)
Writes the message to the specified JSON writer.
public void WriteTo(Utf8JsonWriter writer)
Parameters
writer
Utf8JsonWriterThe UTF-8 JSON writer.