1.73.0 (latest) 1.69.0 1.68.0 1.60.0 1.59.0 1.55.0 1.50.0

    public class AuthorizationCodeWebApp

Thread safe OAuth 2.0 authorization code flow for a web application that persists end-user credentials.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> AuthorizationCodeWebApp

## Inherited Members

[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.Web](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Web.md.txt)

## Assembly

Google.Apis.Auth.dll

## Constructors

### AuthorizationCodeWebApp(IAuthorizationCodeFlow, string, string)

    public AuthorizationCodeWebApp(IAuthorizationCodeFlow flow, string redirectUri, string state)

Constructs a new authorization code installed application with the given flow and code receiver.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `flow` | `IAuthorizationCodeFlow` |
| `redirectUri` | `string` |
| `state` | `string` |

## Fields

### StateKey

    public const string StateKey = "oauth_"

The state key. As part of making the request for authorization code we save the original request to verify
that this server create the original request.

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### StateRandomLength

    public const int StateRandomLength = 8

The length of the random number which will be added to the end of the state parameter.

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `int` |   |

## Properties

### Flow

    public IAuthorizationCodeFlow Flow { get; }

Gets the authorization code flow.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `IAuthorizationCodeFlow` |   |

### RedirectUri

    public string RedirectUri { get; }

Gets the OAuth2 callback redirect URI.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### State

    public string State { get; }

Gets the state which is used to navigate back to the page that started the OAuth flow.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

## Methods

### AuthorizeAsync(string, CancellationToken)

    public Task<AuthorizationCodeWebApp.AuthResult> AuthorizeAsync(string userId, CancellationToken taskCancellationToken)

Asynchronously authorizes the web application to access user's protected data.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `userId` | `string` User identifier |
| `taskCancellationToken` | `CancellationToken` Cancellation token to cancel an operation |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `TaskAuthorizationCodeWebAppAuthResult` | Auth result object which contains the user's credential or redirect URI for the authorization server |

### ShouldRequestAuthorizationCode(TokenResponse)

    public bool ShouldRequestAuthorizationCode(TokenResponse token)

Determines the need for retrieval of a new authorization code, based on the given token and the
authorization code flow.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `token` | `TokenResponse` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` |   |

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