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

    public sealed class FileSourcedExternalAccountCredential : ExternalAccountCredential, IHttpUnsuccessfulResponseHandler, ICredential, IConfigurableHttpClientInitializer, ITokenAccessWithHeaders, ITokenAccess, IHttpExecuteInterceptor

File-sourced credentials as described in
<https://google.aip.dev/auth/4117#determining-the-subject-token-in-file-sourced-credentials>.

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

## Implements

[IHttpUnsuccessfulResponseHandler](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.IHttpUnsuccessfulResponseHandler), [ICredential](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ICredential), [IConfigurableHttpClientInitializer](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.IConfigurableHttpClientInitializer), [ITokenAccessWithHeaders](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ITokenAccessWithHeaders), [ITokenAccess](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ITokenAccess), [IHttpExecuteInterceptor](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Http.IHttpExecuteInterceptor)

## Inherited Members

[ExternalAccountCredential.Audience](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ExternalAccountCredential#Google_Apis_Auth_OAuth2_ExternalAccountCredential_Audience) [ExternalAccountCredential.SubjectTokenType](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ExternalAccountCredential#Google_Apis_Auth_OAuth2_ExternalAccountCredential_SubjectTokenType) [ExternalAccountCredential.ServiceAccountImpersonationUrl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ExternalAccountCredential#Google_Apis_Auth_OAuth2_ExternalAccountCredential_ServiceAccountImpersonationUrl) [ExternalAccountCredential.WorkforcePoolUserProject](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ExternalAccountCredential#Google_Apis_Auth_OAuth2_ExternalAccountCredential_WorkforcePoolUserProject) [ExternalAccountCredential.ClientId](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ExternalAccountCredential#Google_Apis_Auth_OAuth2_ExternalAccountCredential_ClientId) [ExternalAccountCredential.ClientSecret](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ExternalAccountCredential#Google_Apis_Auth_OAuth2_ExternalAccountCredential_ClientSecret) [ExternalAccountCredential.UniverseDomain](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ExternalAccountCredential#Google_Apis_Auth_OAuth2_ExternalAccountCredential_UniverseDomain) [ExternalAccountCredential.RequestAccessTokenAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ExternalAccountCredential#Google_Apis_Auth_OAuth2_ExternalAccountCredential_RequestAccessTokenAsync_System_Threading_CancellationToken_) [ServiceCredential.TokenServerUrl](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_TokenServerUrl) [ServiceCredential.Clock](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_Clock) [ServiceCredential.AccessMethod](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_AccessMethod) [ServiceCredential.HttpClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_HttpClient) [ServiceCredential.Scopes](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_Scopes) [ServiceCredential.Token](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_Token) [ServiceCredential.QuotaProject](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_QuotaProject) [ServiceCredential.Initialize(ConfigurableHttpClient)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_Initialize_Google_Apis_Http_ConfigurableHttpClient_) [ServiceCredential.InterceptAsync(HttpRequestMessage, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_InterceptAsync_System_Net_Http_HttpRequestMessage_System_Threading_CancellationToken_) [ServiceCredential.HandleResponseAsync(HandleUnsuccessfulResponseArgs)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_HandleResponseAsync_Google_Apis_Http_HandleUnsuccessfulResponseArgs_) [ServiceCredential.GetAccessTokenForRequestAsync(string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_GetAccessTokenForRequestAsync_System_String_System_Threading_CancellationToken_) [ServiceCredential.GetAccessTokenWithHeadersForRequestAsync(string, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ServiceCredential#Google_Apis_Auth_OAuth2_ServiceCredential_GetAccessTokenWithHeadersForRequestAsync_System_String_System_Threading_CancellationToken_) [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.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

## Remarks

This credential type does not validate the credential configuration. A security
risk occurs when a credential configuration configured with malicious urls
is used.
You should validate credential configurations provided by untrusted sources.
See [Security requirements when using credential configurations from an external source](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials) for more details.

## Properties

### SubjectTokenFilePath

    public string SubjectTokenFilePath { get; }

The file path from which to obtain the subject token.

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

### SubjectTokenJsonFieldName

    public string SubjectTokenJsonFieldName { get; }

If set, the subject token file content will be parsed as JSON and the
value in the field with name [SubjectTokenJsonFieldName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.FileSourcedExternalAccountCredential#Google_Apis_Auth_OAuth2_FileSourcedExternalAccountCredential_SubjectTokenJsonFieldName)
will be returned as the subject token.

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

## Methods

### GetSubjectTokenAsyncImpl(CancellationToken)

    protected override Task<string> GetSubjectTokenAsyncImpl(CancellationToken taskCancellationToken)

Gets the subject token to be exchanged for the access token.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `taskCancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://learn.microsoft.com/dotnet/api/system.string` |   |

**Overrides** [ExternalAccountCredential.GetSubjectTokenAsyncImpl(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.ExternalAccountCredential#Google_Apis_Auth_OAuth2_ExternalAccountCredential_GetSubjectTokenAsyncImpl_System_Threading_CancellationToken_)

### ToGoogleCredential()

    public GoogleCredential ToGoogleCredential()

Creates a [GoogleCredential](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.GoogleCredential) from this credential.

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

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