1.73.0 (latest) 1.69.0 1.68.0 1.60.0 1.59.0 1.55.0 1.50.0

    public class LocalServerCodeReceiver : ICodeReceiver

OAuth 2.0 verification code receiver that runs a local server on a free port and waits for a call with the
authorization verification code.

## Inheritance

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

## Implements

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

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

## Assembly

Google.Apis.Auth.dll

## Constructors

### LocalServerCodeReceiver()

    public LocalServerCodeReceiver()

Create an instance of [LocalServerCodeReceiver](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.md.txt).

### LocalServerCodeReceiver(string)

    public LocalServerCodeReceiver(string closePageResponse)

Create an instance of [LocalServerCodeReceiver](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.md.txt).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `closePageResponse` | `string` Custom close page response for this instance |

### LocalServerCodeReceiver(string, CallbackUriChooserStrategy)

    public LocalServerCodeReceiver(string closePageResponse, LocalServerCodeReceiver.CallbackUriChooserStrategy strategy)

Create an instance of [LocalServerCodeReceiver](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.md.txt).

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `closePageResponse` | `string` Custom close page response for this instance |
| `strategy` | `LocalServerCodeReceiverCallbackUriChooserStrategy` The strategy to use to determine the callback URI |

## Properties

### RedirectUri

    public string RedirectUri { get; }

Gets the redirected URI.

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

## Methods

### OpenBrowser(string)

    protected virtual bool OpenBrowser(string url)

Open a browser and navigate to a URL.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `url` | `string` URL to navigate to |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `bool` | true if browser was launched successfully, false otherwise |

### ReceiveCodeAsync(AuthorizationCodeRequestUrl, CancellationToken)

    public Task<AuthorizationCodeResponseUrl> ReceiveCodeAsync(AuthorizationCodeRequestUrl url, CancellationToken taskCancellationToken)

Receives the authorization code.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `url` | `AuthorizationCodeRequestUrl` The authorization code request URL |
| `taskCancellationToken` | `CancellationToken` Cancellation token |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `TaskAuthorizationCodeResponseUrl` | The authorization code response |

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