1.73.0 (latest) 1.69.0 1.68.0 1.60.0 1.59.0 1.55.0 1.50.0

    public class PkceGoogleAuthorizationCodeFlow : GoogleAuthorizationCodeFlow, IPkceAuthorizationCodeFlow, IAuthorizationCodeFlow, IDisposable

Google authorization flow implementation that supports PKCE as described in <https://www.rfc-editor.org/rfc/rfc7636>
and <https://developers.google.com/identity/protocols/oauth2/native-app>.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [AuthorizationCodeFlow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt) \> [GoogleAuthorizationCodeFlow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt) \> PkceGoogleAuthorizationCodeFlow

## Implements

[IPkceAuthorizationCodeFlow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IPkceAuthorizationCodeFlow.md.txt), [IAuthorizationCodeFlow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.IAuthorizationCodeFlow.md.txt), [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

## Inherited Members

[GoogleAuthorizationCodeFlow.ProjectId](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_ProjectId) [GoogleAuthorizationCodeFlow.RevokeTokenUrl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_RevokeTokenUrl) [GoogleAuthorizationCodeFlow.includeGrantedScopes](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_includeGrantedScopes) [GoogleAuthorizationCodeFlow.IncludeGrantedScopes](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_IncludeGrantedScopes) [GoogleAuthorizationCodeFlow.LoginHint](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_LoginHint) [GoogleAuthorizationCodeFlow.Prompt](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_Prompt) [GoogleAuthorizationCodeFlow.Nonce](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_Nonce) [GoogleAuthorizationCodeFlow.UserDefinedQueryParams](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_UserDefinedQueryParams) [GoogleAuthorizationCodeFlow.CreateAuthorizationCodeRequest(string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_CreateAuthorizationCodeRequest_System_String_) [GoogleAuthorizationCodeFlow.RevokeTokenAsync(string, string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_RevokeTokenAsync_System_String_System_String_System_Threading_CancellationToken_) [GoogleAuthorizationCodeFlow.ShouldForceTokenRetrieval()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.GoogleAuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_GoogleAuthorizationCodeFlow_ShouldForceTokenRetrieval) [AuthorizationCodeFlow.TokenServerUrl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_TokenServerUrl) [AuthorizationCodeFlow.AuthorizationServerUrl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_AuthorizationServerUrl) [AuthorizationCodeFlow.ClientSecrets](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_ClientSecrets) [AuthorizationCodeFlow.DataStore](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_DataStore) [AuthorizationCodeFlow.Scopes](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_Scopes) [AuthorizationCodeFlow.HttpClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_HttpClient) [AuthorizationCodeFlow.AccessMethod](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_AccessMethod) [AuthorizationCodeFlow.Clock](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_Clock) [AuthorizationCodeFlow.LoadTokenAsync(string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_LoadTokenAsync_System_String_System_Threading_CancellationToken_) [AuthorizationCodeFlow.DeleteTokenAsync(string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_DeleteTokenAsync_System_String_System_Threading_CancellationToken_) [AuthorizationCodeFlow.ExchangeCodeForTokenAsync(string, string, string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_ExchangeCodeForTokenAsync_System_String_System_String_System_String_System_Threading_CancellationToken_) [AuthorizationCodeFlow.CreateAuthorizationCodeTokenRequest(string, string, string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_CreateAuthorizationCodeTokenRequest_System_String_System_String_System_String_) [AuthorizationCodeFlow.ExchangeCodeForTokenAsync(string, AuthorizationCodeTokenRequest, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_ExchangeCodeForTokenAsync_System_String_Google_Apis_Auth_OAuth2_Requests_AuthorizationCodeTokenRequest_System_Threading_CancellationToken_) [AuthorizationCodeFlow.RefreshTokenAsync(string, string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_RefreshTokenAsync_System_String_System_String_System_Threading_CancellationToken_) [AuthorizationCodeFlow.FetchTokenAsync(string, TokenRequest, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_FetchTokenAsync_System_String_Google_Apis_Auth_OAuth2_Requests_TokenRequest_System_Threading_CancellationToken_) [AuthorizationCodeFlow.Dispose()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Flows.AuthorizationCodeFlow.md.txt#Google_Apis_Auth_OAuth2_Flows_AuthorizationCodeFlow_Dispose) [object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

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

## Constructors

### PkceGoogleAuthorizationCodeFlow(Initializer)

    public PkceGoogleAuthorizationCodeFlow(GoogleAuthorizationCodeFlow.Initializer initializer)

Creates a new instance from the given initializer.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `initializer` | `GoogleAuthorizationCodeFlowInitializer` |

## Methods

### CreateAuthorizationCodeRequest(string, out string)

    public 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)

    public 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_)