1.73.0 (latest) 1.69.0 1.68.0 1.60.0 1.59.0 1.55.0 1.50.0

    public interface IPkceAuthorizationCodeFlow : IAuthorizationCodeFlow, IDisposable

Authorization flow that supports Proof Key for Code Exchange (PKCE)
as described in <https://www.rfc-editor.org/rfc/rfc7636>.

## Inherited Members

[IAuthorizationCodeFlow.AccessMethod](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_IAuthorizationCodeFlow_AccessMethod) [IAuthorizationCodeFlow.Clock](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_IAuthorizationCodeFlow_Clock) [IAuthorizationCodeFlow.DataStore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_IAuthorizationCodeFlow_DataStore) [IAuthorizationCodeFlow.LoadTokenAsync(string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_IAuthorizationCodeFlow_LoadTokenAsync_System_String_System_Threading_CancellationToken_) [IAuthorizationCodeFlow.DeleteTokenAsync(string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_IAuthorizationCodeFlow_DeleteTokenAsync_System_String_System_Threading_CancellationToken_) [IAuthorizationCodeFlow.CreateAuthorizationCodeRequest(string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_IAuthorizationCodeFlow_CreateAuthorizationCodeRequest_System_String_) [IAuthorizationCodeFlow.ExchangeCodeForTokenAsync(string, string, string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_IAuthorizationCodeFlow_ExchangeCodeForTokenAsync_System_String_System_String_System_String_System_Threading_CancellationToken_) [IAuthorizationCodeFlow.RefreshTokenAsync(string, string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_IAuthorizationCodeFlow_RefreshTokenAsync_System_String_System_String_System_Threading_CancellationToken_) [IAuthorizationCodeFlow.RevokeTokenAsync(string, string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_IAuthorizationCodeFlow_RevokeTokenAsync_System_String_System_String_System_Threading_CancellationToken_) [IAuthorizationCodeFlow.ShouldForceTokenRetrieval()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_IAuthorizationCodeFlow_ShouldForceTokenRetrieval) [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.md.txt)

## Assembly

Google.Apis.Auth.dll

## Remarks

If you are writing your own authorization flow to be used with [AuthorizationCodeInstalledApp](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.md.txt)
make sure you implement this interface if you need to support PKCE.
See <https://developers.google.com/identity/protocols/oauth2/native-app> for how Google supports PKCE.

## Methods

### CreateAuthorizationCodeRequest(string, out string)

    AuthorizationCodeRequestUrl CreateAuthorizationCodeRequest(string redirectUri, out string codeVerifier)

Creates an authorization code request with the specified redirect URI.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `redirectUri` | `string` The redirect URI for the authorization code request. |
| `codeVerifier` | `string` The code verifier associated to the code challenge that should be included in the returned [AuthorizationCodeRequestUrl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Requests.AuthorizationCodeRequestUrl.md.txt). Note this is an ```csharp out ``` parameter. <br /> |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `AuthorizationCodeRequestUrl` | An [AuthorizationCodeRequestUrl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Requests.AuthorizationCodeRequestUrl.md.txt) subclass instance that includes the code challenge and code challenge method associated with `codeVerifier`. |

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

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

Asynchronously exchanges an authorization code for an access token.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `userId` | `string` User identifier. |
| `code` | `string` Authorization code received from the authorization server. |
| `codeVerifier` | `string` The PKCE code verifier to include in the exchange request. When called by the authentication library, this will be the same value specified by the ```csharp codeVerifier ``` out parameter in an earlier call to CreateAuthorizationCodeRequest. |
| `redirectUri` | `string` Redirect URI which is used in the token request. |
| `taskCancellationToken` | `CancellationToken` Cancellation token to cancel operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `TaskTokenResponse` | Token response which contains the access token. |

## Extension Method

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