You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(csharp/src/Drivers/BigQuery): Add support for AAD/Entra authentication (#2655)
- Adds support for users to login with their Entra / Azure AD account
- Adds a retry concept to the driver that will check whether a token
needs to be refreshed and then invoke a delegate so an outside caller
can perform the token update. Will only go this path if the user has
defined a handler for UpdateToken.
- Includes long running tests to demonstrate the concept:

---------
Co-authored-by: David Coe <>
Copy file name to clipboardExpand all lines: csharp/src/Drivers/BigQuery/readme.md
+32-6Lines changed: 32 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,13 +34,17 @@ The ADBC driver passes the configured credentials to BigQuery, but you may need
34
34
35
35
The following parameters can be used to configure the driver behavior. The parameters are case sensitive.
36
36
37
+
**adbc.bigquery.access_token**<br>
38
+
Sets the access token to use as the credential. Currently, this is for Microsoft Entra, but this could be used for other OAuth implementations as well.
39
+
40
+
**adbc.bigquery.audience_uri**<br>
41
+
Sets the audience URI for the authentication token. Currently, this is for Microsoft Entra, but this could be used for other OAuth implementations as well.
42
+
37
43
**adbc.bigquery.allow_large_results**<br>
38
44
Sets the [AllowLargeResults](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.QueryOptions#Google_Cloud_BigQuery_V2_QueryOptions_AllowLargeResults) value of the QueryOptions to `true` if configured; otherwise, the default is `false`.
39
45
40
46
**adbc.bigquery.auth_type**<br>
41
-
Required. Must be `user` or `service`
Required. Must be `user`, `aad` (for Microsoft Entra) or `service`.
44
48
45
49
**adbc.bigquery.billing_project_id**<br>
46
50
The [Project ID](https://cloud.google.com/resource-manager/docs/creating-managing-projects) used for accessing billing BigQuery. If not specified, will default to the detected project ID.
Optional. Sets the timeout (in seconds) for the GetQueryResultsOptions value. If not set, defaults to 5 minutes. Similar to a CommandTimeout.
62
66
67
+
**adbc.bigquery.maximum_retries**<br>
68
+
Optional. The maximum number of retries. Defaults to 5.
69
+
63
70
**adbc.bigquery.max_fetch_concurrency**<br>
64
71
Optional. Sets the [maxStreamCount](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.Storage.V1/latest/Google.Cloud.BigQuery.Storage.V1.BigQueryReadClient#Google_Cloud_BigQuery_Storage_V1_BigQueryReadClient_CreateReadSession_System_String_Google_Cloud_BigQuery_Storage_V1_ReadSession_System_Int32_Google_Api_Gax_Grpc_CallSettings_) for the CreateReadSession method. If not set, defaults to 1.
Optional. Some callers do not need the constraint details when they get the table information and can improve the speed of obtaining the results. Setting this value to `"false"` will not include the constraint details. The default value is `"true"`.
77
84
85
+
**adbc.bigquery.include_public_project_id**<br>
86
+
Include the `bigquery-public-data` project ID with the list of project IDs.
Optional. Sets the [DestinationTable](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.QueryOptions#Google_Cloud_BigQuery_V2_QueryOptions_DestinationTable) value of the QueryOptions if configured. Expects the format to be `{projectId}.{datasetId}.{tableId}` to set the corresponding values in the [TableReference](https://github.com/googleapis/google-api-dotnet-client/blob/6c415c73788b848711e47c6dd33c2f93c76faf97/Src/Generated/Google.Apis.Bigquery.v2/Google.Apis.Bigquery.v2.cs#L9348) class.
80
90
81
91
**adbc.bigquery.project_id**<br>
82
92
The [Project ID](https://cloud.google.com/resource-manager/docs/creating-managing-projects) used for accessing BigQuery. If not specified, will default to detect the projectIds the credentials have access to.
83
93
84
-
**adbc.bigquery.include_public_project_id**<br>
85
-
Include the `bigquery-public-data` project ID with the list of project IDs.
86
-
87
94
**adbc.bigquery.refresh_token**<br>
88
95
The refresh token used for when the generated OAuth token expires. Required for `user` authentication.
89
96
97
+
**adbc.bigquery.retry_delay_ms**<br>
98
+
Optional The delay between retries. Defaults to 200ms. The retries could take up to `adbc.bigquery.maximum_retries` x `adbc.bigquery.retry_delay_ms` to complete.
99
+
90
100
**adbc.bigquery.scopes**<br>
91
101
Optional. Comma separated list of scopes to include for the credential.
92
102
@@ -119,3 +129,19 @@ The following table depicts how the BigQuery ADBC driver converts a BigQuery typ
119
129
+A JSON string
120
130
121
131
See [Arrow Schema Details](https://cloud.google.com/bigquery/docs/reference/storage/#arrow_schema_details) for how BigQuery handles Arrow types.
132
+
133
+
## Microsoft Entra
134
+
The driver supports authenticating with a [Microsoft Entra](https://learn.microsoft.com/en-us/entra/fundamentals/what-is-entra) ID. For long running operations, the Entra token may timeout if the operation takes longer than the Entra token's lifetime. The driver has the ability to perform token refreshes by subscribing to the `UpdateToken` delegate on the `BigQueryConnection`. In this scenario, the driver will attempt to perform an operation. If that operation fails due to an Unauthorized error, then the token will be refreshed via the `UpdateToken` delegate.
135
+
136
+
Sample code to refresh the token:
137
+
138
+
```
139
+
Dictionary<string,string> properties = ...;
140
+
BigQueryConnection connection = new BigQueryConnection(properties);
In the sample above, when a new token is needed, the delegate is invoked and updates the `adbc.bigquery.access_token` parameter on the connection object.
0 commit comments