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

# FileIdTokenCallback

> Supplies the enterprise OpenID Connect id token the identity assertion grant exchanges, reading it from the file `--idp-id-token-file` names or from the [ODa...

## Definition

**Assembly:** Microsoft.OData.Mcp.Authentication.dll

**Namespace:** Microsoft.OData.Mcp.Authentication.Outbound

**Inheritance:** System.Object

## Syntax

```csharp theme={null}
Microsoft.OData.Mcp.Authentication.Outbound.FileIdTokenCallback
```

## Summary

Supplies the enterprise OpenID Connect id token the identity assertion grant exchanges, reading it from
the file `--idp-id-token-file` names or from the
[ODataMcpAuthConstants.IdTokenEnvironmentVariable](https://ai.easyaf.dev/odata-mcp/api-reference/Microsoft/OData/Mcp/Authentication/Outbound/ODataMcpAuthConstants.md#idtokenenvironmentvariable) environment variable.

## Remarks

Per `specs/v3/AUTHENTICATION.md` "Grants → Identity Assertion Grant" the id token is never passed on
argv: a process list is world-readable on every platform this tool ships to, and an id token is a bearer
credential for the end user's enterprise identity. The file is re-read on every call rather than cached,
so a daemon whose sidecar rotates the token picks the new one up without a restart, and per
`AUTH-12` nothing here ever logs, elicits, or echoes the token itself — only the path it came from.

## Examples

```csharp theme={null}
var callback = new FileIdTokenCallback(options.IdpIdTokenFile);

var providerOptions = new IdentityAssertionGrantProviderOptions
{
    ClientId = options.ClientId,
    IdpClientId = options.IdpClientId,
    IdTokenCallback = callback.ReadAsync
};
```

## Constructors

### &#x20;.ctor

Initializes a new instance of the [FileIdTokenCallback](https://ai.easyaf.dev/odata-mcp/api-reference/Microsoft/OData/Mcp/Authentication/Outbound/FileIdTokenCallback.md) class.

#### Syntax

```csharp theme={null}
public FileIdTokenCallback(string path)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `path` | `string?` | The path of the file holding a UTF-8 id token, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) to read [ODataMcpAuthConstants.IdTokenEnvironmentVariable](https://ai.easyaf.dev/odata-mcp/api-reference/Microsoft/OData/Mcp/Authentication/Outbound/ODataMcpAuthConstants.md#idtokenenvironmentvariable) instead. |

#### Remarks

A [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) path is not an error: the environment variable is the other documented
source, and which of the two an operator configured is only knowable when the token is actually
needed.

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public Object()
```

## Properties

### &#x20;Path

Gets the path of the file the id token is read from, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when only the
environment variable is consulted.

#### Syntax

```csharp theme={null}
public string Path { get; }
```

#### Property Value

Type: `string?`

## Methods

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public virtual bool Equals(object obj)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `obj` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### &#x20;ReadAsync

Reads the id token, preferring the configured file over the environment variable.

#### Syntax

```csharp theme={null}
public System.Threading.Tasks.Task<string> ReadAsync(ModelContextProtocol.Authentication.IdentityAssertionGrantContext context, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `context` | `ModelContextProtocol.Authentication.IdentityAssertionGrantContext` | The resource and authorization server URLs the SDK discovered, unused by this source. |
| `cancellationToken` | `System.Threading.CancellationToken` | The token that cancels the file read. |

#### Returns

Type: `System.Threading.Tasks.Task<string>`
The trimmed id token.

#### Exceptions

| Exception | Description |
| - | - |
| `InvalidOperationException` | Thrown when the configured file does not exist, when it is empty, or when neither a file nor |
| [ODataMcpAuthConstants.IdTokenEnvironmentVariable](https://ai.easyaf.dev/odata-mcp/api-reference/Microsoft/OData/Mcp/Authentication/Outbound/ODataMcpAuthConstants.md#idtokenenvironmentvariable) supplies a token. | |

#### Examples

```csharp theme={null}
SdkAuth.IdentityAssertionGrantIdTokenCallback callback = new FileIdTokenCallback(path).ReadAsync;
```

#### Remarks

The token is trimmed because both sources routinely pick up a trailing newline — a shell
redirection, a Kubernetes projected volume — and a JWT with a newline on the end is rejected by
every token endpoint with an error that says nothing about whitespace. Failures name the source,
never the value.

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `objA` | `object?` | - |
| `objB` | `object?` | - |

#### Returns

Type: `bool`

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

```csharp theme={null}
public virtual string ToString()
```

#### Returns

Type: `string?`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.