# Interface IAuthorizationCodeFlow (1.73.0)

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

- [1.73.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow)
- [1.69.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.69.0/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow)
- [1.68.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.68.0/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow)
- [1.60.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.60.0/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow)
- [1.59.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.59.0/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow)
- [1.55.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.55.0/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow)
- [1.50.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.50.0/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow)

    public interface IAuthorizationCodeFlow : IDisposable

OAuth 2.0 authorization code flow that manages and persists end-user credentials.

## Inherited Members

[IDisposable.Dispose()](https://learn.microsoft.com/dotnet/api/system.idisposable.dispose)

## Namespace

[Google.Apis.Auth.OAuth2.Flows](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows)

## Assembly

Google.Apis.Auth.dll

## Properties

### AccessMethod

    IAccessMethod AccessMethod { get; }

Gets the method for presenting the access token to the resource server.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.IAccessMethod` |   |

### Clock

    IClock Clock { get; }

Gets the clock.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.IClock` |   |

### DataStore

    IDataStore DataStore { get; }

Gets the data store used to store the credentials.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.IDataStore` |   |

## Methods

### CreateAuthorizationCodeRequest(string)

    AuthorizationCodeRequestUrl CreateAuthorizationCodeRequest(string redirectUri)

Creates an authorization code request with the specified redirect URI.

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Requests.AuthorizationCodeRequestUrl` |   |

### DeleteTokenAsync(string, CancellationToken)

    Task DeleteTokenAsync(string userId, CancellationToken taskCancellationToken)

Asynchronously deletes the user's token using the flow's
[IDataStore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.IDataStore).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `userId` | `https://learn.microsoft.com/dotnet/api/system.string` User identifier. |
| `taskCancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` Cancellation token to cancel operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` |   |

### ExchangeCodeForTokenAsync(string, string, string, CancellationToken)

    Task<TokenResponse> ExchangeCodeForTokenAsync(string userId, string code, string redirectUri, CancellationToken taskCancellationToken)

Asynchronously exchanges an authorization code for an access token.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `userId` | `https://learn.microsoft.com/dotnet/api/system.string` User identifier. |
| `code` | `https://learn.microsoft.com/dotnet/api/system.string` Authorization code received from the authorization server. |
| `redirectUri` | `https://learn.microsoft.com/dotnet/api/system.string` Redirect URI which is used in the token request. |
| `taskCancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` Cancellation token to cancel operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Responses.TokenResponse` | Token response which contains the access token. |

### LoadTokenAsync(string, CancellationToken)

    Task<TokenResponse> LoadTokenAsync(string userId, CancellationToken taskCancellationToken)

Asynchronously loads the user's token using the flow's
[IDataStore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Store.IDataStore).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `userId` | `https://learn.microsoft.com/dotnet/api/system.string` User identifier |
| `taskCancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` Cancellation token to cancel operation |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Responses.TokenResponse` | Token response |

### RefreshTokenAsync(string, string, CancellationToken)

    Task<TokenResponse> RefreshTokenAsync(string userId, string refreshToken, CancellationToken taskCancellationToken)

Asynchronously refreshes an access token using a refresh token.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `userId` | `https://learn.microsoft.com/dotnet/api/system.string` User identifier. |
| `refreshToken` | `https://learn.microsoft.com/dotnet/api/system.string` Refresh token which is used to get a new access token. |
| `taskCancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` Cancellation token to cancel operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Responses.TokenResponse` | Token response which contains the access token and the input refresh token. |

### RevokeTokenAsync(string, string, CancellationToken)

    Task RevokeTokenAsync(string userId, string token, CancellationToken taskCancellationToken)

Asynchronously revokes the specified token. This method disconnects the user's account from the OAuth 2.0
application. It should be called upon removing the user account from the site.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `userId` | `https://learn.microsoft.com/dotnet/api/system.string` User identifier. |
| `token` | `https://learn.microsoft.com/dotnet/api/system.string` Access token to be revoked. |
| `taskCancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` Cancellation token to cancel operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | `true` if the token was revoked successfully. |

**Remarks** If revoking the token succeeds, the user's credential is removed from the data store and the user MUST
authorize the application again before the application can access the user's private resources.

### ShouldForceTokenRetrieval()

    bool ShouldForceTokenRetrieval()

Indicates if a new token needs to be retrieved and stored regardless of normal circumstances.

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

## Extension Method

[Utilities.ThrowIfNull\<T\>(T, string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Utilities#Google_Apis_Util_Utilities_ThrowIfNull__1___0_System_String_)