1.73.0 (latest) 1.69.0 1.68.0 1.60.0 1.59.0 1.55.0 1.50.0

    public static class CredentialFactory

A Google credential factory.

## Inheritance

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

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

## Methods

### FromFile(string, string)

    public static GoogleCredential FromFile(string credentialPath, string credentialType)

Creates a credential of the specified type from a file that contains JSON credential data.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `credentialPath` | `string` The path to the credential file. |
| `credentialType` | `string` The type of credential to be loaded. Valid strings can be found in [JsonCredentialParameters](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.JsonCredentialParameters.md.txt). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `GoogleCredential` | The created credential. |

### FromFileAsync(string, string, CancellationToken)

    public static Task<GoogleCredential> FromFileAsync(string credentialPath, string credentialType, CancellationToken cancellationToken)

Creates a credential of the specified type from a file that contains JSON credential data.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `credentialPath` | `string` The path to the credential file. |
| `credentialType` | `string` The type of credential to be loaded. Valid strings can be found in [JsonCredentialParameters](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.JsonCredentialParameters.md.txt). |
| `cancellationToken` | `CancellationToken` The cancellation token to cancel the operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `TaskGoogleCredential` | The created credential. |

### FromFileAsync\<T\>(string, CancellationToken)

    public static Task<T> FromFileAsync<T>(string credentialPath, CancellationToken cancellationToken)

Creates a credential of the specified type from a file that contains JSON credential data.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `credentialPath` | `string` The path to the credential file. |
| `cancellationToken` | `CancellationToken` The cancellation token to cancel the operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Task` | A task that will be completed with the created credential. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type of the credential to create. |

### FromFile\<T\>(string)

    public static T FromFile<T>(string credentialPath)

Creates a credential of the specified type from a file that contains JSON credential data.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `credentialPath` | `string` The path to the credential file. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` | The created credential. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type of the credential to create. |

### FromJson(string, string)

    public static GoogleCredential FromJson(string json, string credentialType)

Creates a credential of the specified type from a string that contains JSON credential data.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `json` | `string` The string that contains the JSON credential data. |
| `credentialType` | `string` The type of credential to be loaded. Valid strings can be found in [JsonCredentialParameters](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.JsonCredentialParameters.md.txt). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `GoogleCredential` | The created credential. |

### FromJson\<T\>(string)

    public static T FromJson<T>(string json)

Creates a credential of the specified type from a string that contains JSON credential data.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `json` | `string` The string that contains the JSON credential data. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` | The created credential. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type of the credential to create. |

### FromStreamAsync\<T\>(Stream, CancellationToken)

    public static Task<T> FromStreamAsync<T>(Stream stream, CancellationToken cancellationToken)

Creates a credential of the specified type from a stream that contains JSON credential data.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `stream` | `Stream` The stream that contains the JSON credential data. |
| `cancellationToken` | `CancellationToken` The cancellation token to cancel the operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Task` | A task that will be completed with the created credential. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type of the credential to create. |

### FromStream\<T\>(Stream)

    public static T FromStream<T>(Stream stream)

Creates a credential of the specified type from a stream that contains JSON credential data.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `stream` | `Stream` The stream that contains the JSON credential data. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` | The created credential. |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` | The type of the credential to create. |