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

# OAuthRefresh

```csharp
public static class OAuthRefresh
```

## Methods

### ClientCredentialsAsync()

```csharp
public static Task<OAuthGrant> ClientCredentialsAsync(HttpMessageHandler handler, ConnectorManifest manifest, (string? Id, string? Secret) client, IReadOnlyDictionary<string, string?>? settings, Uri? baseAddress, CancellationToken cancellationToken)
```

Mints a token for the client itself, with no user behind it.

#### Parameters

**handler** `HttpMessageHandler` *required*

What sends the request.

**manifest** `ConnectorManifest` *required*

Whose `token_url` applies.

**client** `(string Id, string Secret)` *required*

The OAuth client's id and secret.

**settings** `IReadOnlyDictionary\<string, string\>` *required*

**baseAddress** `Uri` *required*

**cancellationToken** `CancellationToken` *required*

Cancels the call.

#### Returns

`Task<OAuthGrant>`

### ExchangeAsync()

```csharp
public static Task<OAuthGrant> ExchangeAsync(HttpMessageHandler handler, ConnectorManifest manifest, (string? Id, string? Secret) client, string code, string? redirectUri, OAuthPkce? pkce, IReadOnlyDictionary<string, string?>? settings, CancellationToken cancellationToken)
```

Redeems the code an approval page gave.

#### Parameters

**handler** `HttpMessageHandler` *required*

What sends the request.

**manifest** `ConnectorManifest` *required*

Whose `token_url` applies.

**client** `(string Id, string Secret)` *required*

The OAuth client's id and secret.

**code** `string` *required*

The code to redeem.

**redirectUri** `string` *required*

Where the page sent the code, or [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) for an app approved with no redirect.

**pkce** `OAuthPkce` *required*

The approval request's PKCE verifier, if it sent one.

**settings** `IReadOnlyDictionary\<string, string\>` *required*

The connection's values, which pick a sandbox.

**cancellationToken** `CancellationToken` *required*

Cancels the call.

#### Returns

`Task<OAuthGrant>`

### RedeemAsync()

```csharp
public static Task<OAuthGrant> RedeemAsync(HttpMessageHandler handler, ConnectorManifest manifest, (string? Id, string? Secret) client, string refreshToken, Uri? baseAddress, IReadOnlyDictionary<string, string?>? settings, CancellationToken cancellationToken)
```

Redeems a refresh token at the manifest's `auth.token_url`.

#### Parameters

**handler** `HttpMessageHandler` *required*

What sends the request.

**manifest** `ConnectorManifest` *required*

Whose `token_url` applies.

**client** `(string Id, string Secret)` *required*

The OAuth client's id and secret.

**refreshToken** `string` *required*

**baseAddress** `Uri` *required*

Where to send the request instead of the vendor.

**settings** `IReadOnlyDictionary\<string, string\>` *required*

The connection's values, which pick a sandbox.

**cancellationToken** `CancellationToken` *required*

#### Returns

`Task<OAuthGrant>`

### RevokeAsync()

```csharp
public static Task<bool> RevokeAsync(HttpMessageHandler handler, ConnectorManifest manifest, (string? Id, string? Secret) client, string refreshToken, Uri? baseAddress, IReadOnlyDictionary<string, string?>? settings, CancellationToken cancellationToken)
```

Revokes a refresh token at the manifest's `auth.revoke_url` (RFC 7009), which ends the grant behind it. Does nothing for a vendor that declares no revocation.

#### Parameters

**handler** `HttpMessageHandler` *required*

What sends the request.

**manifest** `ConnectorManifest` *required*

Whose `revoke_url` applies.

**client** `(string Id, string Secret)` *required*

The OAuth client's id and secret.

**refreshToken** `string` *required*

The token to revoke.

**baseAddress** `Uri` *required*

Where to send the request instead of the vendor.

**settings** `IReadOnlyDictionary\<string, string\>` *required*

The connection's values, which pick a sandbox.

**cancellationToken** `CancellationToken` *required*

Cancels the call.

#### Returns

`Task<bool>`

Whether the manifest declares a revocation, which then succeeded.


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