# Class ServiceCredential.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.ServiceCredential.Initializer)
- [1.69.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.69.0/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer)
- [1.68.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.68.0/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer)
- [1.60.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.60.0/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer)
- [1.59.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.59.0/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer)
- [1.55.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.55.0/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer)
- [1.50.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.50.0/Google.Apis.Auth.OAuth2.ServiceCredential.Initializer)

    public class ServiceCredential.Initializer

An initializer class for the service credential.

## Inheritance

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

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

## Derived Types

[ComputeCredential.Initializer](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ComputeCredential.Initializer) [ExternalAccountCredential.Initializer](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ExternalAccountCredential.Initializer) [ImpersonatedCredential.Initializer](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ImpersonatedCredential.Initializer) [ServiceAccountCredential.Initializer](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer)

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

Constructs a new initializer using the given token server URL.

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

## Properties

### AccessMethod

    public IAccessMethod AccessMethod { get; set; }

Gets or sets the method for presenting the access token to the resource server.
The default value is [BearerToken.AuthorizationHeaderAccessMethod](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.BearerToken.AuthorizationHeaderAccessMethod).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.IAccessMethod` |   |

### Clock

    public IClock Clock { get; set; }

Gets or sets the clock used to refresh the token when it expires. The default value is
[Default](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.SystemClock#Google_Apis_Util_SystemClock_Default).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.IClock` |   |

### DefaultExponentialBackOffPolicy

    public ExponentialBackOffPolicy DefaultExponentialBackOffPolicy { get; set; }

Indicates which of exceptions and / or HTTP status codes are automatically retried using exponential backoff.
The default value is [RecommendedOrDefault](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.ExponentialBackOffPolicy#Google_Apis_Http_ExponentialBackOffPolicy_RecommendedOrDefault) which means retries will be
executed as recommended by each service. For services that have no specific recommendations
[UnsuccessfulResponse503](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.ExponentialBackOffPolicy#Google_Apis_Http_ExponentialBackOffPolicy_UnsuccessfulResponse503) will be used, which means HTTP Status code 503
will be retried with exponential backoff.
If set to [None](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.ExponentialBackOffPolicy#Google_Apis_Http_ExponentialBackOffPolicy_None) no automatic retries will happen.
Calling code may still specify custom retries by configuring [HttpClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_HttpClient).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.ExponentialBackOffPolicy` |   |

### HttpClientFactory

    public IHttpClientFactory HttpClientFactory { get; set; }

Gets or sets the factory for creating a [HttpClient](https://learn.microsoft.com/dotnet/api/system.net.http.httpclient) instance.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.IHttpClientFactory` |   |

### QuotaProject

    public string QuotaProject { get; set; }

The ID of the project associated to this credential for the purposes of
quota calculation and billing. May be null.

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

### Scopes

    public IEnumerable<string> Scopes { get; set; }

Scopes to request during the authorization grant. May be null or empty.

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

**Remarks** If the scopes are pre-granted through the environement, like in GCE where scopes are granted to the VM,
scopes set here will be ignored.

### TokenServerUrl

    public string TokenServerUrl { get; }

Gets the token server URL.

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

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