Tag: 谷歌的API,DOTNET客户端

我在哪里可以找到ServiceAccountCredential

我在使用asp.net c#的google api工作,我的目标是使用服务帐户访问google api。 我已导入所有需要的dll以创建服务帐户以访问管理员function(admin sdk)。 但我找不到ServiceAccountCredential。 我如何在我的项目中实现这一点?

使用C#和Sheets API v4更新Cell

有没有人有一个很好的C#示例用于使用v4 API更新单元格? 我在使用Google表格API v4的开发者网站上获得了获取单元格值c#示例。 我试图修改示例以更新值为“Tom”的单元格。 我坚持使用SpreadSheets.Values.Update的设置。 using Google.Apis.Auth.OAuth2; using Google.Apis.Sheets.v4; using Google.Apis.Sheets.v4.Data; using Google.Apis.Services; using Google.Apis.Util.Store; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace GoogleSheetsAPI4_v1console { class Program { // If modifying these scopes, delete your previously saved credentials // at ~/.credentials/sheets.googleapis.com-dotnet-quickstart.json static string[] Scopes = { SheetsService.Scope.Spreadsheet […]

Google .NET API – 除FileDataStore之外的任何其他DataStore?

我正在使用Google .NET API从谷歌分析中获取分析数据。 这是我开始身份validation的代码: IAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer { ClientSecrets = new ClientSecrets { ClientId = googleApiClientId, ClientSecret = googleApiClientSecret }, Scopes = new[] { Google.Apis.Analytics.v3.AnalyticsService.Scope.AnalyticsReadonly }, DataStore = new Google.Apis.Util.Store.FileDataStore(“Test_GoogleApi”) }); 它使用FileDataStore作为文件存储在本地用户配置文件中。 我在ASP.NET应用程序中运行此代码,因此我无法真正使用该FileDataStore,因此我需要的是另一种获取数据的方法。 Google.Apis.Util.Store仅包含FileDataStore和IDataStore的接口。 在我开始实现自己的DataStore之前 – 是否还有其他可供下载的DataStore对象? 谢谢

在C#中使用AccessType = Offline的Google Analytics OAuth

我想使用OAuth使用Google AnalyticsAPI。 我正在使用此库: http : //code.google.com/p/google-api-dotnet-client/ 以下代码用于身份validation: var credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = “…”, ClientSecret = “…” }, new[] {Google.Apis.Analytics.v3.AnalyticsService.Scope.AnalyticsReadonly}, “user”, CancellationToken.None, new FileDataStore(“Analytics.Auth.Store”)).Result; var service = new Google.Apis.Analytics.v3.AnalyticsService( new BaseClientService.Initializer { HttpClientInitializer = credential, ApplicationName = “…”, }); 我可以将它与refresh_token一起使用,这样我就不必每隔几天就接受一次授权请求吗? 类似于这个问题的答案: 服务帐户Google Analytics OAuth AccessType =离线C#

是否可以使用json密钥而不是p12密钥来获取服务帐户凭据?

我在C#中使用“Google.Apis.Bigquery.v2客户端库”。 我使用“服务帐户”授权Google BigQuery(请参阅http://www.afterlogic.com/mailbee-net/docs/OAuth2GoogleServiceAccounts.html )。 要创建X509证书,请使用Google Developers Console中的p12密钥。 但是,现在json键是默认值。 我可以用它代替p12键吗? 我有以下代码: string serviceAccountEmail = “xxxx@developer.gserviceaccount.com”; 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 = […]

.NET Google api 1.7 beta使用刷新令牌进行身份validation

我一直在关注Oauth .Net Google Apis,以便通过OAuth进行身份validation并使用Google驱动Apis。 具体来说,我想使用我已经存储的刷新令牌,以便使用它来实例化GoogleDrive服务。 我找到了像https://code.google.com/p/google-api-dotnet-client/source/browse/Tasks.SimpleOAuth2/Program.cs?repo=samples这样的示例 这似乎使用“GoogleWebAuthorizationBroker.AuthorizeAsync”,但我不确定如何使用该方法使用刷新令牌而不是您在此示例中似乎提供的客户机密码。

Google API V 3.0 .Net库和Google OAuth2如何处理刷新令牌

在我的应用程序中,我使用带有Google OAuth2的Google API V 3.0 .Net库来同步Google日历和Outlook日历。 我使用下面的代码来获取Google.Apis.Calendar.v3.CalendarService服务对象。 在身份validation期间,我存储了Json文件,并从中请求了Google.Apis.Auth.OAuth2.UserCredential对象。 private Google.Apis.Auth.OAuth2.UserCredential GetGoogleOAuthCredential() { GoogleTokenModel _TokenData = new GoogleTokenModel(); String JsonFilelocation = “jsonFileLocation; Google.Apis.Auth.OAuth2.UserCredential credential = null; using (var stream = new FileStream(JsonFilelocation, FileMode.Open, FileAccess.Read)) { Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.Folder = “Tasks.Auth.Store”; credential = Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync( Google.Apis.Auth.OAuth2.GoogleClientSecrets.Load(stream).Secrets, new[] { Google.Apis.Calendar.v3.CalendarService.Scope.Calendar }, “user”, CancellationToken.None, new FileDataStore(“OGSync.Auth.Store”)).Result; } return credential; } 请求服务对象代码是: Google.Apis.Calendar.v3.CalendarService […]

GoogleWebAuthorizationBroker.AuthorizeAsync挂起

我们的网站需要从后面的代码(asp.net mvc应用程序)上传video到youtube。 我正在尝试获取Google凭据,但是当我调用AuthorizeAsync时,应用程序就会挂起。 我一直在找一个解决方案,似乎没有人帮忙。 我已经搜索了谷歌和堆栈溢出的明显。 我发现的大多数提到应用程序可能无法访问appdata文件夹,因此我尝试将文件夹更改为c驱动器,d驱动器和实际的inetpub位置。 我测试过,发现我能够将应用程序写入这些位置。 更具体地说,用户是我们的管理员,客户将video上传给我们,管理员批准他们。 当管理员批准它们时,它会发布在我们的YouTube帐户上。 管理员不应该做任何事情,只需单击批准按钮。 为了使这成为一个实际问题,我该怎样做才能通过AuthorizeAsync? 如果您需要更多信息,请告诉我 UserCredential credential; GoogleWebAuthorizationBroker.Folder = “YouTube.Auth.Store”; using (var stream = new FileStream(CredentialsPath, FileMode.Open, FileAccess.Read)) { credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, // This OAuth 2.0 access scope allows an application to upload files to the // authenticated user’s YouTube channel, but doesn’t allow other types of […]