C# ile "Google.Apis.Bigquery.v2 İstemci Kitaplığı" kullanıyorum.Servis hesabı kimlik bilgileri için p12 anahtarı yerine json anahtarını kullanmak mümkün mü?
Google BigQuery'ye "Hizmet Hesabı" nı kullanarak izin veriyorum (bkz. http://www.afterlogic.com/mailbee-net/docs/OAuth2GoogleServiceAccounts.html). X509 sertifikasını oluşturmak için p12 anahtarını Google Developers Console'dan kullanıyorum. Ancak, şu anda json anahtar varsayılan değerdir. Bunun yerine p12 anahtarını kullanabilir miyim?
string serviceAccountEmail = "[email protected]";
X509Certificate2 certificate;
using (Stream stream = new FileStream(@"C:\key.p12", FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (MemoryStream ms = new MemoryStream())
{
stream.CopyTo(ms);
certificate = new X509Certificate2(ms.ToArray(), "notasecret", X509KeyStorageFlags.Exportable);
}
}
// Create credentials
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] {
BigqueryService.Scope.Bigquery,
BigqueryService.Scope.CloudPlatform,
},
}.FromCertificate(certificate));
// Create the service
BaseClientService.Initializer initializer = new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "My Application",
GZipEnabled = true,
};
BigqueryService service = new BigqueryService(initializer);
var projects = service.Projects.List().Execute();
Benzer (yanıtlanmamış) soru şu anda buradadır: http://stackoverflow.com/questions/30884184 –
Bu akışı kullanmayı denediniz: http://stackoverflow.com/questions/19977864/nativeapplicationclient-is-not-supported-any ama BQ için? – Ryan
Bu aslında çok yakın. ServiceAccountCredential (UserCredential değil) için benzer bir örneğiniz var mı? –