3

I require to query data using Google BigQuery API, calling with service account.

However I am struggling to find .NET Samples, and there was no documentation included with the binary (Google.Apis.Bigquery.dll). Can anybody provide me with sample usage for C#.NET?

2
  • possible duplicate of Google BigQuery with .NET documentation/ samples Commented Apr 10, 2014 at 20:03
  • Hi Sir, This is an outdataed example and outdated namespaces, and even I am looking for an example with service account along with the Latest NUGET pacakge namespaces information. Commented Apr 10, 2014 at 20:42

1 Answer 1

3

This information is coming from: Google APIs Client Library for .NET

That example shows how to use a service account with the Google+ api. I edited it a little for use with BigQuery.

using System; using Google.Apis.Auth.OAuth2; using System.Security.Cryptography.X509Certificates; using Google.Apis.Bigquery.v2; using Google.Apis.Services; //Install-Package Google.Apis.Bigquery.v2 namespace GoogleBigQueryServiceAccount { class Program { private static String ACTIVITY_ID = "z12gtjhq3qn2xxl2o224exwiqruvtda0i"; static void Main(string[] args) { Console.WriteLine("BigQuery API - Service Account"); Console.WriteLine("=========================="); String serviceAccountEmail = "SERVICE_ACCOUNT_EMAIL_HERE"; var certificate = new X509Certificate2(@"key.p12", "notasecret", X509KeyStorageFlags.Exportable); ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { Scopes = new[] { BigqueryService.Scope.DevstorageReadOnly } }.FromCertificate(certificate)); // Create the service. var service = new BigqueryService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "BigQuery API Sample", }); //Note: all your requests will run against Service. } } 

}

Sign up to request clarification or add additional context in comments.

2 Comments

What is "notasecret"? Would should go here?
Its just text leave it as is

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.