# Class AuthContext (2.66.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.66.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.AuthContext)
- [2.63.0](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/2.63.0/Grpc.Core.AuthContext)
- [2.48.0](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/2.48.0/Grpc.Core.AuthContext)

    public class AuthContext

Authentication context for a call.
AuthContext is the only reliable source of truth when it comes to authenticating calls.
Using any other call/context properties for authentication purposes is wrong and inherently unsafe.
Note: experimental API that can change or be removed without any prior notice.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> AuthContext

## Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Grpc.Core](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core)

## Assembly

Grpc.Core.Api.dll

## Constructors

### AuthContext(string?, Dictionary\<string, List\<AuthProperty\>\>)

    public AuthContext(string? peerIdentityPropertyName, Dictionary<string, List<AuthProperty>> properties)

Initializes a new instance of the [AuthContext](https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.AuthContext) class.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `peerIdentityPropertyName` | `https://learn.microsoft.com/dotnet/api/system.string` Peer identity property name. |
| `properties` | ``https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2https://learn.microsoft.com/dotnet/api/system.stringSystem.Collections.Generic.List`1https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.AuthProperty`` Multimap of auth properties by name. |

## Properties

### IsPeerAuthenticated

    public bool IsPeerAuthenticated { get; }

Returns `true` if the peer is authenticated.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### PeerIdentity

    public IEnumerable<AuthProperty> PeerIdentity { get; }

Gets properties that represent the peer identity (there can be more than one). Returns an empty collection
if the peer is not authenticated.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.AuthProperty` |   |

### PeerIdentityPropertyName

    public string? PeerIdentityPropertyName { get; }

Gets the name of the property that indicates the peer identity. Returns `null`
if the peer is not authenticated.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### Properties

    public IEnumerable<AuthProperty> Properties { get; }

Gets the auth properties of this context.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.AuthProperty` |   |

## Methods

### FindPropertiesByName(string)

    public IEnumerable<AuthProperty> FindPropertiesByName(string propertyName)

Returns the auth properties with given name (there can be more than one).
If no properties of given name exist, an empty collection will be returned.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `propertyName` | `https://learn.microsoft.com/dotnet/api/system.string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.AuthProperty` |   |