Manually create and obtain service account credentials to use BigQuery when an application is deployed on premises or to other public clouds. You can set the environment variable to load the credentials using Application Default Credentials, or you can specify the path to load the credentials manually in your application code.
This guide shows you how to load the credentials from a file.
Before you begin
- Follow getting started with authentication to set up and download service account credentials.
Loading credentials from a file
Create credentials in your application from the service account file. Then use the credentials to create a service object with the BigQuery client libraries.
C#
Before trying this sample, follow the C# setup instructions in the
BigQuery Quickstart Using Client Libraries.
For more information, see the
BigQuery C# API reference documentation.
Load the credentials from the JSON file using
GoogleCredential.FromStream(Stream).
After you create a GoogleCredential
, pass it to
BigQueryClient.Create(String,
GoogleCredential) to create the BigQuery service object.
Java
Before trying this sample, follow the Java setup instructions in the
BigQuery Quickstart Using Client Libraries.
For more information, see the
BigQuery Java API reference documentation.
Create a ServiceAccountCredentials
object from a file using ServiceAccountCredentials.fromStream(InputStream).
Pass the credentials to a BigQueryOptions.Builder
and create the BigQuery
service from those options.
Node.js
Before trying this sample, follow the Node.js setup instructions in the
BigQuery Quickstart Using Client Libraries.
For more information, see the
BigQuery Node.js API reference documentation.
Python
Before trying this sample, follow the Python setup instructions in the
BigQuery Quickstart Using Client Libraries.
For more information, see the
BigQuery Python API reference documentation.
Use google.oauth2.service_account.Credentials.from_service_account_file
to authenticate with a service account key file.
Create a BigQuery Client
using the credentials.
What's next
- Learn about other ways to authenticate your application to access the BigQuery API.
- Learn more about authenticating server to server production applications.