> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# AzureActiveDirectorySqlAuthProvider

> Provides a custom authentication method that gets a [SqlAuthenticationToken](https://learn.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlauthenticatio...

## Definition

**Assembly:** CloudNimble.EasyAF.Data.EF6.dll

**Namespace:** CloudNimble.EasyAF.Data

**Inheritance:** Microsoft.Data.SqlClient.SqlAuthenticationProvider

## Syntax

```csharp theme={"dark"}
CloudNimble.EasyAF.Data.AzureActiveDirectorySqlAuthProvider
```

## Summary

Provides a custom authentication method that gets a [SqlAuthenticationToken](https://learn.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlauthenticationtoken) from Azure Identity for the executing context.

## Constructors

### <Icon icon="hammer" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> .ctor

#### Syntax

```csharp theme={"dark"}
public AzureActiveDirectorySqlAuthProvider()
```

## Methods

### <Icon icon="code-merge" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> AcquireTokenAsync <Badge color="blue">Override</Badge>

Request token from the provider using the specified [SqlAuthenticationParameters](https://learn.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlauthenticationparameters).
Uses DefaultAzureCredential to obtain an access token for SQL Database authentication.

#### Syntax

```csharp theme={"dark"}
public override System.Threading.Tasks.Task<Microsoft.Data.SqlClient.SqlAuthenticationToken> AcquireTokenAsync(Microsoft.Data.SqlClient.SqlAuthenticationParameters parameters)
```

#### Parameters

| Name         | Type                                                   | Description                                    |
| ------------ | ------------------------------------------------------ | ---------------------------------------------- |
| `parameters` | `Microsoft.Data.SqlClient.SqlAuthenticationParameters` | The authentication parameters from SQL Client. |

#### Returns

Type: `System.Threading.Tasks.Task<Microsoft.Data.SqlClient.SqlAuthenticationToken>`
A SqlAuthenticationToken containing the access token and expiration time.

### <Icon icon="code-merge" iconType="duotone" color="#E0EC32" size={24} className="mr-2" /> IsSupported <Badge color="blue">Override</Badge>

Returns a flag indicating if the requested [SqlAuthenticationMethod](https://learn.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlauthenticationmethod) is supported by this custom [SqlAuthenticationProvider](https://learn.microsoft.com/dotnet/api/microsoft.data.sqlclient.sqlauthenticationprovider).
This provider supports ActiveDirectoryDeviceCodeFlow authentication method.

#### Syntax

```csharp theme={"dark"}
public override bool IsSupported(Microsoft.Data.SqlClient.SqlAuthenticationMethod authenticationMethod)
```

#### Parameters

| Name                   | Type                                               | Description                                     |
| ---------------------- | -------------------------------------------------- | ----------------------------------------------- |
| `authenticationMethod` | `Microsoft.Data.SqlClient.SqlAuthenticationMethod` | The authentication method to check for support. |

#### Returns

Type: `bool`
True if the authentication method is ActiveDirectoryDeviceCodeFlow; otherwise, false.
