Show / Hide Table of Contents

# Class OpenIddictServerBuilder

Exposes the necessary methods required to configure the OpenIddict server services.

##### Inheritance

System.Object
OpenIddictServerBuilder

##### Inherited Members

System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)

###### Namespace: Microsoft.Extensions.DependencyInjection

###### Assembly: cs.temp.dll.dll

##### Syntax

    public class OpenIddictServerBuilder

### Constructors

#### OpenIddictServerBuilder(IServiceCollection)

Initializes a new instance of OpenIddictServerBuilder.

##### Declaration

    public OpenIddictServerBuilder(IServiceCollection services)

##### Parameters

Type | Name | Description
--- | --- | ---
IServiceCollection | services | The services collection.

### Properties

#### Services

Gets the services collection.

##### Declaration

    public IServiceCollection Services { get; }

##### Property Value

Type | Description
--- | ---
IServiceCollection |

### Methods

#### AcceptAnonymousClients()

Makes client identification optional so that token, introspection and revocation requests that don't specify a client_id are not automatically rejected. Enabling this option is NOT recommended.

##### Declaration

    public OpenIddictServerBuilder AcceptAnonymousClients()

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.

#### AddDevelopmentEncryptionCertificate()

Registers (and generates if necessary) a user-specific development encryption certificate.

##### Declaration

    public OpenIddictServerBuilder AddDevelopmentEncryptionCertificate()

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.

#### AddDevelopmentEncryptionCertificate(X500DistinguishedName)

Registers (and generates if necessary) a user-specific development encryption certificate.

##### Declaration

    public OpenIddictServerBuilder AddDevelopmentEncryptionCertificate(X500DistinguishedName subject)

##### Parameters

Type | Name | Description
--- | --- | ---
X500DistinguishedName | subject | The subject name associated with the certificate.

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.

#### AddEncryptionCredentials(EncryptingCredentials)

Registers encryption credentials.

##### Declaration

    public OpenIddictServerBuilder AddEncryptionCredentials(EncryptingCredentials credentials)

##### Parameters

Type | Name | Description
--- | --- | ---
EncryptingCredentials | credentials | The encrypting credentials.

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.

#### AddEncryptionKey(SecurityKey)

Registers an encryption key.

##### Declaration

    public OpenIddictServerBuilder AddEncryptionKey(SecurityKey key)

##### Parameters

Type | Name | Description
--- | --- | ---
SecurityKey | key | The security key.

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.

#### AddEphemeralEncryptionKey()

Registers a new ephemeral encryption key. Ephemeral encryption keys are automatically discarded when the application shuts down and payloads encrypted using this key are automatically invalidated. This method should only be used during development. On production, using a X.509 certificate stored in the machine store is recommended.

##### Declaration

    public OpenIddictServerBuilder AddEphemeralEncryptionKey()

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.

#### AddEphemeralEncryptionKey(String)

Registers a new ephemeral encryption key. Ephemeral encryption keys are automatically discarded when the application shuts down and payloads encrypted using this key are automatically invalidated. This method should only be used during development. On production, using a X.509 certificate stored in the machine store is recommended.

##### Declaration

    public OpenIddictServerBuilder AddEphemeralEncryptionKey(string algorithm)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | algorithm | The algorithm associated with the encryption key.

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.

#### AddEventHandler(OpenIddictServerHandlerDescriptor)

Registers an event handler using the specified descriptor.

##### Declaration

    public OpenIddictServerBuilder AddEventHandler(OpenIddictServerHandlerDescriptor descriptor)

##### Parameters

Type | Name | Description
--- | --- | ---
OpenIddictServerHandlerDescriptor | descriptor | The handler descriptor.

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.

#### AddEventHandler<TContext>(Action<OpenIddictServerHandlerDescriptor.Builder<TContext>>)

Registers an event handler using the specified configuration delegate.

##### Declaration

    public OpenIddictServerBuilder AddEventHandler<TContext>(Action<OpenIddictServerHandlerDescriptor.Builder<TContext>> configuration)
        where TContext : OpenIddictServerEvents.BaseContext

##### Parameters

Type | Name | Description
--- | --- | ---
System.Action<OpenIddictServerHandlerDescriptor.Builder<TContext>> | configuration | The configuration delegate.

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.

##### Type Parameters

Name | Description
--- | ---
TContext | The event context type.

#### Configure(Action<OpenIddictServerOptions>)

Amends the default OpenIddict server configuration.

##### Declaration

    public OpenIddictServerBuilder Configure(Action<OpenIddictServerOptions> configuration)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Action<OpenIddictServerOptions> | configuration | The delegate used to configure the OpenIddict options.

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.

##### Remarks

This extension can be safely called multiple times.

#### RemoveEventHandler(OpenIddictServerHandlerDescriptor)

Removes the event handler that matches the specified descriptor.

##### Declaration

    public OpenIddictServerBuilder RemoveEventHandler(OpenIddictServerHandlerDescriptor descriptor)

##### Parameters

Type | Name | Description
--- | --- | ---
OpenIddictServerHandlerDescriptor | descriptor | The descriptor corresponding to the handler to remove.

##### Returns

Type | Description
--- | ---
OpenIddictServerBuilder | The OpenIddictServerBuilder.