Show / Hide Table of Contents

Class ApiKeyAuthenticationPolicy

A PipelinePolicy that uses an ApiKeyCredential to set a value on a PipelineRequest to authenticate with the cloud service.

Inheritance
System.Object
PipelinePolicy
ApiKeyAuthenticationPolicy
Namespace: System.Dynamic.ExpandoObject
Assembly: System.ClientModel.dll
Syntax
[System.Runtime.CompilerServices.Nullable(0)]
[System.Runtime.CompilerServices.NullableContext(1)]
public class ApiKeyAuthenticationPolicy : System.ClientModel.Primitives.PipelinePolicy

Methods

CreateBasicAuthorizationPolicy(ApiKeyCredential)

Create a new instance of the ApiKeyAuthenticationPolicy class, where the credential value will be set in the Authorization header on the PipelineRequest with a Basic prefix.

Declaration
public static System.ClientModel.Primitives.ApiKeyAuthenticationPolicy CreateBasicAuthorizationPolicy (System.ClientModel.ApiKeyCredential credential);
Parameters
ApiKeyCredential credential

The ApiKeyCredential used to authenticate requests.

Returns
ApiKeyAuthenticationPolicy

CreateBearerAuthorizationPolicy(ApiKeyCredential)

Create a new instance of the ApiKeyAuthenticationPolicy class, where the credential value will be set in the Authorization header on the PipelineRequest with a Bearer prefix.

Declaration
public static System.ClientModel.Primitives.ApiKeyAuthenticationPolicy CreateBearerAuthorizationPolicy (System.ClientModel.ApiKeyCredential credential);
Parameters
ApiKeyCredential credential

The ApiKeyCredential used to authenticate requests.

Returns
ApiKeyAuthenticationPolicy

CreateHeaderApiKeyPolicy(ApiKeyCredential, String, String)

Create a new instance of the ApiKeyAuthenticationPolicy class, where the credential value will be specified in a request header.

Declaration
public static System.ClientModel.Primitives.ApiKeyAuthenticationPolicy CreateHeaderApiKeyPolicy (System.ClientModel.ApiKeyCredential credential, string headerName, string keyPrefix = null);
Parameters
ApiKeyCredential credential

The ApiKeyCredential used to authenticate requests.

System.String headerName

The name of the request header used to send the key credential in the request.

System.String keyPrefix

A prefix to prepend before the key credential in the header value. If provided, the prefix string will be followed by a space and then the credential string. For example, setting valuePrefix to "SharedAccessKey" will result in the header value being set to "SharedAccessKey {credential.Key}".

Returns
ApiKeyAuthenticationPolicy

Process(PipelineMessage, IReadOnlyList<PipelinePolicy>, Int32)

Process the provided PipelineMessage according to the intended purpose of this PipelinePolicyinstance. Derived types must pass control to the next PipelinePolicy in the pipeline by calling ProcessNext(PipelineMessage, IReadOnlyList<PipelinePolicy>, Int32).

Declaration
public override sealed void Process (System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex);
Parameters
PipelineMessage message

The PipelineMessage to process.

System.Collections.Generic.IReadOnlyList<PipelinePolicy> pipeline

The collection of PipelinePolicy instances in the ClientPipeline instance whose Send(PipelineMessage) method was called to invoke this method.

System.Int32 currentIndex

The index of this policy in the pipeline policy list. This value should be passed to ProcessNext(PipelineMessage, IReadOnlyList<PipelinePolicy>, Int32) to pass control to the next policy in the pipeline.

ProcessAsync(PipelineMessage, IReadOnlyList<PipelinePolicy>, Int32)

Process the provided PipelineMessage according to the intended purpose of this PipelinePolicyinstance. Derived types must pass control to the next PipelinePolicy in the pipeline by calling ProcessNextAsync(PipelineMessage, IReadOnlyList<PipelinePolicy>, Int32).

Declaration
[System.Diagnostics.DebuggerStepThrough]
public override sealed System.Threading.Tasks.ValueTask ProcessAsync (System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList<System.ClientModel.Primitives.PipelinePolicy> pipeline, int currentIndex);
Parameters
PipelineMessage message

The PipelineMessage to process.

System.Collections.Generic.IReadOnlyList<PipelinePolicy> pipeline

The collection of PipelinePolicy instances in the ClientPipeline instance whose SendAsync(PipelineMessage) method was called to invoke this method.

System.Int32 currentIndex

The index of this policy in the pipeline policy list. This value should be passed to ProcessNextAsync(PipelineMessage, IReadOnlyList<PipelinePolicy>, Int32) to pass control to the next policy in the pipeline.

Returns
System.Threading.Tasks.ValueTask

Back to top Azure SDK for .NET