Michael
Michael

Reputation: 23

BigQuery Credentials in .NET

Is there some way I can use OAuth 2.0 to get credentials for my BigQuery account and use them to upload? I have seen the solution where I set the environment variables, but that is not an option for my code. Is there another way I could go about doing it so that I did not have to provide a credential file or set any environment variable? I have an OAuth 2.0 client ID set up in BigQuery, but I'm not quite sure how to use it for upload in .NET.

Thanks!

Upvotes: 0

Views: 351

Answers (1)

Tim Swena
Tim Swena

Reputation: 14786

The simplest way to authenticate will be to download a service account JSON key file. See the guide for getting started with authentication on Google Cloud APIs for detailed instructions for creating and downloading service account credentials.

If you cannot set the GOOGLE_APPLICATION_CREDENTIALS environment variable, you can explicitly load the credentials from the JSON file using GoogleCredential.FromStream(Stream)

Once you have created a GoogleCredential, you can pass it in to the BigQueryClient.Create(String, GoogleCredential).

Upvotes: 3

Related Questions