# Class ServiceAccountCredential.Initializer (1.73.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [1.73.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer)
- [1.69.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.69.0/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer)
- [1.68.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.68.0/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer)
- [1.60.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.60.0/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer)
- [1.59.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.59.0/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer)
- [1.55.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.55.0/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer)
- [1.50.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.50.0/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer)

    public class ServiceAccountCredential.Initializer : ServiceCredential.Initializer

An initializer class for the service account credential.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [ServiceCredential](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential)[Initializer](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer) \> ServiceAccountCredential.Initializer

## Inherited Members

[ServiceCredential.Initializer.TokenServerUrl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer#Google_Apis_Auth_OAuth2_ServiceCredential_Initializer_TokenServerUrl) [ServiceCredential.Initializer.Clock](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer#Google_Apis_Auth_OAuth2_ServiceCredential_Initializer_Clock) [ServiceCredential.Initializer.AccessMethod](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer#Google_Apis_Auth_OAuth2_ServiceCredential_Initializer_AccessMethod) [ServiceCredential.Initializer.HttpClientFactory](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer#Google_Apis_Auth_OAuth2_ServiceCredential_Initializer_HttpClientFactory) [ServiceCredential.Initializer.DefaultExponentialBackOffPolicy](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer#Google_Apis_Auth_OAuth2_ServiceCredential_Initializer_DefaultExponentialBackOffPolicy) [ServiceCredential.Initializer.QuotaProject](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer#Google_Apis_Auth_OAuth2_ServiceCredential_Initializer_QuotaProject) [ServiceCredential.Initializer.Scopes](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer#Google_Apis_Auth_OAuth2_ServiceCredential_Initializer_Scopes) [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)

## Assembly

Google.Apis.Auth.dll

## Constructors

### Initializer(string)

    public Initializer(string id)

Constructs a new initializer using the given id.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `id` | `https://learn.microsoft.com/dotnet/api/system.string` |

### Initializer(string, string)

    public Initializer(string id, string tokenServerUrl)

Constructs a new initializer using the given id and the token server URL.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `id` | `https://learn.microsoft.com/dotnet/api/system.string` |
| `tokenServerUrl` | `https://learn.microsoft.com/dotnet/api/system.string` |

## Properties

### Id

    public string Id { get; }

Gets the service account ID (typically an e-mail address).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### Key

    public RSA Key { get; set; }

Gets or sets the key which is used to sign the request, as specified in
<https://developers.google.com/accounts/docs/OAuth2ServiceAccount#computingsignature>.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.security.cryptography.rsa` |   |

### KeyId

    public string KeyId { get; set; }

Gets or sets the service account key ID.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### ProjectId

    public string ProjectId { get; set; }

The project ID associated with this credential.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### UniverseDomain

    public string UniverseDomain { get; set; }

The universe domain this credential belongs to.
Won't be null.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### UseJwtAccessWithScopes

    public bool UseJwtAccessWithScopes { get; set; }

Gets or sets the flag preferring use of self-signed JWTs over OAuth tokens when OAuth scopes are explicitly set.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### User

    public string User { get; set; }

Gets or sets the email address of the user the application is trying to impersonate in the service
account flow or `null`.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

## Methods

### FromCertificate(X509Certificate2)

    public ServiceAccountCredential.Initializer FromCertificate(X509Certificate2 certificate)

Extracts a [Key](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer#Google_Apis_Auth_OAuth2_ServiceAccountCredential_Initializer_Key) from the given certificate.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `certificate` | `https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceAccountCredentialhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer` |   |

### FromPrivateKey(string)

    public ServiceAccountCredential.Initializer FromPrivateKey(string privateKey)

Extracts the [Key](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer#Google_Apis_Auth_OAuth2_ServiceAccountCredential_Initializer_Key) from the given PKCS8 private key.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `privateKey` | `https://learn.microsoft.com/dotnet/api/system.string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceAccountCredentialhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer` |   |

## Extension Method

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