Tag: google api

Google API使用身份validation服务帐户上传文件

我正在尝试通过API Google Drive发送文件,但是,我找不到任何有关如何使用身份validation服务帐户执行C#上传文件的文档。 我下载了Daimto库,但是,当我们使用身份validationClientId和ClientSecret时,他使用DriveService类上传。 但是使用身份validation进行帐户服务后,他返回到PlusService类,发现无法以这种方式上传文件。 有人能帮我吗? 最好的祝福 使用validation服务帐户 public PlusService GoogleAuthenticationServiceAccount() { String serviceAccountEmail = “106842951064-6s4s95s9u62760louquqo9gu70ia3ev2@developer.gserviceaccount.com”; //var certificate = new X509Certificate2(@”key.p12″, “notasecret”, X509KeyStorageFlags.Exportable); var certificate = new X509Certificate2(@”key.p12″, “notasecret”, X509KeyStorageFlags.Exportable); ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { Scopes = new[] { PlusService.Scope.PlusMe } }.FromCertificate(certificate)); // Create the service. var service = new PlusService(new BaseClientService.Initializer() […]

在下载的DLL中显示错误

我正在使用谷歌api版本3集成google Install-Package Google.Apis.Calendar.v3 ,使用NuGet包Install-Package Google.Apis.Calendar.v3并引用此链接 。 运行Web应用程序时出现错误: System.IO.FileLoadException **:无法加载文件或程序集’ System.Net.Http.Primitives , Version = 2.2.22.0 ,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a’或其依赖项之一。 定位的程序集的清单定义与程序集引用不匹配。 ( 来自HRESULT的exception:0x80131040 )—> System.IO.FileLoadException :无法加载文件或程序集’System.Net.Http.Primitives,Version = 1.5.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a’或其中一个依赖。 定位的程序集的清单定义与程序集引用不匹配。 (HRESULTexception:0x80131040) 我正在使用的Web配置文件是: 包配置如下: bith类似于参考链接中的内容 更新: —内部exception堆栈跟踪结束— Microsoft.Runtime.CompilerServices.TaskAwaiter.HhleForNonSuccess(任务任务),位于Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd的Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(任务任务) (任务任务)在Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult() at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 59 — End of inner exception stack trace — at […]

谷歌c#Api,从v2.3变为v3

我有以下代码使用C#v2.3 api查询谷歌分析: string username = “SAMPLE@SAMPLE.COM”; string pass = “PASS”; string gkey = “?key=XXXXXXXXXXXXXXXXXXXXXXXXXXX”; string dataFeedUrl = “https://www.google.com/analytics/feeds/data” + gkey; AnalyticsService service = new AnalyticsService(“API Sample”); service.setUserCredentials(username, pass); DataQuery query1 = new DataQuery(dataFeedUrl); query1.Ids = “ga:34197921”; query1.Dimensions = “ga:medium,ga:campaign,ga:date,ga:isMobile,ga:isTablet,ga:searchKeyword,ga:hostname”; query1.Metrics = “ga:visits,ga:visitors,ga:visitBounceRate,ga:goalStartsAll,ga:goalCompletionsAll,ga:goal1Starts,ga:goal1Completions,ga:goal2Starts,ga:goal2Completions,ga:goal3Starts,ga:goal3Completions,ga:goal4Starts,ga:goal4Completions,ga:adCost,ga:totalValue”; query1.Sort = “ga:date,ga:hour”; query1.NumberToRetrieve = 50; query1.GAStartDate = new DateTime(2012, 1, 2).ToString(“yyyy-MM-dd”); query1.GAEndDate […]

NativeApplicationClient不受支持

在我的Visual Stuidio Win表单项目中使用此代码时。 var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, ClientId, ClientSecret); 我收到了一条消息 不再支持NativeApplicationClient,它将在1.7.0-beta中删除。 考虑使用支持.NET 4,.NET for Windows Store应用程序,Windows Phone 7.5和8以及便携式类库的新Google.Apis.Auth NuGet软件包 我在用 install-package Google.Apis.Authentication -pre 如果我添加Google.apis.auth而不是Google.Apis.Authentication它甚至没有NativeApplicationClient。 但我无法找到任何有关我使用NativeApplicationClient的内容的信息。

使用API​​密钥分析报告v4

我需要在我使用asp.net Web表单(C#)构建的CMS Web应用程序的仪表板页面中集成来自Google Analytics的非常基本的报告。 我记得我能够在2015年使用API​​ V3进行的测试中做到这一点,但是现在,使用V4,我总是会收到一条错误消息,即validation需要OAuth2。 我需要访问我拥有的特定分析帐户,而不是在CMS中导航的用户帐户! 因此,我使用Google API Manager提供的API KEY。 我已经给了API Key所有权限。 API密钥类似于:“d471c3ce04612f143ff0Be319aac2e17d0159add” 这是代码 using Google.Apis.AnalyticsReporting.v4; using Google.Apis.Services; using System; using Google.Apis.AnalyticsReporting.v4.Data; using System.Collections.Generic; using System.Threading.Tasks; using System.IO; using Google.Apis.Auth.OAuth2; using System.Threading; using Google.Apis.Util.Store; using System.Web; public static class GoogleAnalyticsAPI { static string vmcApiKey = “<>”; public static void Test() { AnalyticsReportingService ars = […]

带有.Net CLient库的Gmail API:缺少草稿消息

我正在尝试使用.Net客户端库在Gmail中创建草稿。 我可以成功登录并检索草稿列表,以便身份validation和api正常工作。 现在我需要创建Draft类的实例并将其发送到API。 但草案信息需要看起来像什么? 我在https://developers.google.com/gmail/api/v1/reference/users/drafts/create上填写API资源管理器并不重要,我的草稿始终为空。 另外,当我从C#代码中执行此操作时,我需要将draft.Message.Raw字段设置为其他内容我收到错误: Missing draft message [400]

Google+ API plus.me

问题:如何使用带有“me”参数的people.get? 我知道如何在使用https://www.googleapis.com/plus/v1/people/{id}?key={key}时获取json对象 但是当我使用“我”作为id时,我应该包括哪些参数? (我在auth中使用response_type=code ) 编辑:(固定) 我正在使用ASP.NET,我找到了这个链接 ,但访问令牌json的POST请求引发了错误。 发送请求有效,但是当我使用GetResponse() ,我得到错误(400)。 而且我也不确定我使用的uri是否正确: https://accounts.google.com/o/oauth2/token : https://accounts.google.com/o/oauth2/token 编辑2: 问题解决了。 请求很糟糕,因为我在写入Stream之前将参数字符串转换为byte []时使用了UTF32Encoding而不是UTF8Encoding 。 使用UTF8Encoding效果很好。 🙂 我在这个问题之后写的代码: HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri); webRequest.ContentType = “application/x-www-form-urlencoded”; webRequest.Method = “POST”; UTF8Encoding utfenc = new UTF8Encoding(); byte[] bytes = utfenc.GetBytes(parameters); Stream os = null; try // send the post { webRequest.ContentLength = bytes.Length; // […]

如何在C#中列出来自Google Drive API V3的1000多条记录

这是此链接中原始问题的延续。 通过下面的代码,我可以获取1000条记录,但我的驱动器总共有6500条++记录。 搜索谷歌但无法找到正确的解决方案。 根据参考,参数“pageSize”的描述值是“每页返回的最大文件数。可接受的值是1到1000,包括1。(默认值:100)”。 所以这意味着,我们只能获得1000条记录,如果可能的话,那么方式是什么。 另外,我不了解参数“pageToken”,实时使用’nextPageToken’值是什么。 代码:( https://developers.google.com/drive/v3/web/quickstart/dotnet ) namespace gDrive { class Program { static string[] Scopes = { DriveService.Scope.DriveReadonly }; static string ApplicationName = “Drive API .NET Quickstart”; static void Main(string[] args) { UserCredential credential; gDriveTableAdapter gDrive = new gDriveTableAdapter(); using (var stream = new FileStream(“client_secret.json”, FileMode.Open, FileAccess.Read)) { string credPath = System.Environment.GetFolderPath( […]

使用youtube api v3继续获取错误:redirect_uri_mismatch

嗨,我希望有人可以帮助我。 我在本地计算机上有一个Web应用程序(asp.net),我正在尝试使用此示例将video上传到YouTube https://developers.google.com/youtube/v3/code_samples/dotnet#upload_a_video 当我尝试上传video时,我在Google控制台中为Web应用程序设置了客户端ID和密码,打开浏览器选项卡以选择我的一个Google帐户,一旦我输入redirect_uri_mismatch,该页面上的响应详细信息如下: cookie_policy_enforce=false scope=https://www.googleapis.com/auth/youtube.upload response_type=code access_type=offline redirect_uri=http://localhost:55556/authorize/ pageId=[some page id removed here for security reasons] display=page client_id=[some unique id removed here for security reasons].apps.googleusercontent.com 一个有趣的事情是redirect_uri=http://localhost:55556/authorize/与Google控制台中设置的完全不同,client_secrets.json中的那个也是每次我得到端口号更改的错误页面时都不同。 redurecturl和来源在Google控制台中设置如下我想我已添加所有组合以防万一: 授权重定向URI http://localhost/ https://localhost/ http://localhost:50169/AddContent.aspx https://localhost:50169/AddContent.aspx http://localhost:50169 授权的JavaScript起源 http://localhost/ https://localhost/ http://localhost:50169/ https://localhost:50169/ 我不确定为什么错误页面上的redirect-uri与我在Google控制台中指定的任何授权重定向URI都不匹配? 有任何想法吗 ? 也有可能在Google控制台和我的代码中正确设置了所有内容,但这个错误是由其他东西引发的,例如我错过了我的管帐号上的一些设置? 我没有进行任何设置更改,因为我不认为我必须这样做是正确的?

C#中的Google演讲文字API

当flac文件使用Windows的录音机录制手册并使用软件转换器转换时,我的程序从谷歌获得正确的响应。 但是当我使用我的程序记录的文件时,我从谷歌获得了“{”结果“:[]}”。 我该怎么办? 这是我的代码: 寄件人 : private static void CopyStream(FileStream fileStream, Stream requestStream) { var buffer = new byte[32768]; int read; while ((read = fileStream.Read(buffer, 0, buffer.Length)) > 0) { requestStream.Write(buffer, 0, read); } } private static void ConfigureRequest(HttpWebRequest request) { request.KeepAlive = true; request.SendChunked = true; request.ContentType = “audio/x-flac; rate=44100”; request.UserAgent = “Mozilla/5.0 (Windows […]