> ## 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.

# TokenEndpointResponse

> The RFC 6749 section 5.1 successful token response returned from a token endpoint.

## 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.TokenEndpointResponse
```

## Summary

The RFC 6749 section 5.1 successful token response returned from a token endpoint.

## Remarks

Deserialized exclusively through [OutboundOAuthJsonContext](https://learn.microsoft.com/dotnet/api/microsoft.odata.mcp.authentication.outbound.outboundoauthjsoncontext) (AOT: JSON source-gen; no
reflection). This is the RFC 6749 wire shape only; it is \<em>not\</em> the SDK `TokenContainer`
cache/runtime format, which is PascalCase and additionally carries `ObtainedAt`.
[String)](https://learn.microsoft.com/dotnet/api/microsoft.odata.mcp.authentication.outbound.tokenendpointresponse.totokencontainer\(system.string,system.string,system.string,system.string,system.string\)) is the single place that
conversion happens.

## Examples

```csharp theme={null}
var response = JsonSerializer.Deserialize(json, OutboundOAuthJsonContext.Default.TokenEndpointResponse);
var container = response!.ToTokenContainer(
    previousRefreshToken: null,
    clientId: "cli",
    clientSecret: null,
    authorizationServer: metadata.Issuer!,
    tokenEndpointAuthMethod: TokenEndpointClient.AuthMethodNone);
```

## Constructors

### &#x20;.ctor

#### Syntax

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

### &#x20;.ctor Inherited

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

#### Syntax

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

## Properties

### &#x20;AccessToken

Gets or sets the issued access token.

#### Syntax

```csharp theme={null}
public string AccessToken { get; set; }
```

#### Property Value

Type: `string`

### &#x20;ExpiresIn

Gets or sets the lifetime, in seconds, of [TokenEndpointResponse.AccessToken](https://ai.easyaf.dev/odata-mcp/api-reference/Microsoft/OData/Mcp/Authentication/Outbound/TokenEndpointResponse.md#accesstoken), or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when
the server did not advertise one.

#### Syntax

```csharp theme={null}
public System.Nullable<int> ExpiresIn { get; set; }
```

#### Property Value

Type: `System.Nullable<int>?`

### &#x20;RefreshToken

Gets or sets the refresh token, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when the server did not issue one.

#### Syntax

```csharp theme={null}
public string RefreshToken { get; set; }
```

#### Property Value

Type: `string?`

### &#x20;Scope

Gets or sets the space-delimited scope actually granted, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when the server
did not echo it back.

#### Syntax

```csharp theme={null}
public string Scope { get; set; }
```

#### Property Value

Type: `string?`

### &#x20;TokenType

Gets or sets the token type, such as `Bearer`.

#### Syntax

```csharp theme={null}
public string TokenType { get; set; }
```

#### 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;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?`

### &#x20;ToTokenContainer

Maps this wire response onto the SDK `TokenContainer` the cache and the outbound
handler read, stamping `ObtainedAt` at the moment of the call.

#### Syntax

```csharp theme={null}
public ModelContextProtocol.Authentication.TokenContainer ToTokenContainer(string previousRefreshToken, string clientId, string clientSecret, string authorizationServer, string tokenEndpointAuthMethod)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `previousRefreshToken` | `string?` | The refresh token the caller already holds, kept when this response omits one; or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when there is none. |
| `clientId` | `string?` | The client identifier the tokens were issued to, persisted so a cold start can refresh without re-registering. |
| `clientSecret` | `string?` | The client secret, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for a public client. |
| `authorizationServer` | `string` | The issuer the tokens came from. |
| `tokenEndpointAuthMethod` | `string?` | The token endpoint authentication method the grant used, or [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) when none applies. |

#### Returns

Type: `ModelContextProtocol.Authentication.TokenContainer`
A container carrying this response's access token, lifetime, and scope, the effective refresh token,
and the client and server identity the caller supplied.

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentException` | Thrown when *authorizationServer* is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), empty, or whitespace. |
| `InvalidOperationException` | Thrown when [TokenEndpointResponse.AccessToken](https://ai.easyaf.dev/odata-mcp/api-reference/Microsoft/OData/Mcp/Authentication/Outbound/TokenEndpointResponse.md#accesstoken) is [`null`](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null), empty, or whitespace. |

#### Examples

```csharp theme={null}
var refreshed = response.ToTokenContainer(
    previousRefreshToken: current.RefreshToken,
    clientId: current.ClientId,
    clientSecret: current.ClientSecret,
    authorizationServer: current.AuthorizationServer!,
    tokenEndpointAuthMethod: current.TokenEndpointAuthMethod);
```

#### Remarks

RFC 6749 section 6 makes `refresh_token` optional on a refresh response, so an omitted value
means "keep the one you have", never "you no longer have one"; that rule lives here so no grant has
to remember it. An absent `token_type` becomes
[ODataMcpAuthConstants.BearerScheme](https://ai.easyaf.dev/odata-mcp/api-reference/Microsoft/OData/Mcp/Authentication/Outbound/ODataMcpAuthConstants.md#bearerscheme), because the SDK container requires one and every
grant this package implements is a bearer grant.


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