问题标签 [google-api-dotnet-client]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1884 浏览

c# - 如何使用 .net 客户端库获取超过 250 个日历项目?

我正在尝试将 .net 客户端库用于 Google 日历。我可以获取日历列表并获取日历上的事件列表。但是,每个日历我最多可以获得 250 个项目。我如何访问其余部分?我知道 Google.Apis.Calendar.v3.EventsResource.ListRequest 中的“pagetoken”,但是在下面的代码示例中,itemlistreq.PageToken 仍然为空,即使对于超过 250 个项目的日历也是如此。

0 投票
15 回答
57863 浏览

exception - 无法加载文件或程序集 System.Net.Http.Primitives。定位程序集的清单定义与程序集引用不匹配

我正在开发一个使用 Google API 的程序。但是每次我运行我的程序时,我都会收到以下错误:

无法加载文件或程序集“System.Net.Http.Primitives,Version=1.5.0.0,Culture=neutral,PublicKeyToken=b03f5f711d50a3a”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。

我正在使用 Visual Studio 2012 express。我试过关注这个链接并浏览了许多论坛,但似乎没有一个有效。主要问题似乎来自我引用的 DLL 文件“Google.Apis.dll”,它引用了 System.Net.Http.Primitives v1.5.0.0。但是我的程序引用的版本是 2.2.13.0。我尝试让程序引用 v1.5.0.0 代替(我设法找到了 dll 以及 Google.Apis 的源代码),但这只会导致另一个问题,我需要更新版本的 System.Net。 Http.Primitives。

我一直在尝试找到解决此问题的方法,但是我似乎找不到任何可行的方法。谢谢你的时间。

0 投票
1 回答
542 浏览

c# - 该语言不支持“ApplyAuthenticationToRequest”

我正在研究从 Google Cloud Storage 下载 DFA 文件,但由于上述错误,我无法编译他们的示例项目。

具体来说,这发生在“GoogleApisSample”解决方案中的“DownloadReportFileHelper”中。

有没有人遇到过这个问题,如果有,您是否设法解决?

提前致谢。

C

0 投票
0 回答
1428 浏览

c# - DotNetOpenAuth.Oauth2.IAuthorizationState 重复定义

我正在尝试编译一个示例以连接到 Google 日历。

我正在使用 Visual Studio Express 2012

我已经用 NuGet 下载了所需的库

当我尝试构建解决方案时出现此错误:

错误 1 ​​类型 'DotNetOpenAuth.OAuth2.IAuthorizationState' 存在于两个 'C:\Users\Cesc\Documents\Visual Studio 2012\Projects\Prova1\packages\DotNetOpenAuth.OAuth2.Client.5.0.0-alpha1\lib\net45- full\DotNetOpenAuth.OAuth2.Client.dll' 和 'C:\Users\Cesc\Documents\Visual Studio 2012\Projects\Prova1\packages\Google.Apis.Authentication.1.5.0-beta\lib\net40\DotNetOpenAuth.dll ' C:\Users\Cesc\Documents\Visual Studio 2012\Projects\Prova1\Prova1\Program.cs 120 20 Prova1

我试图删除一些库,但后来我丢失了引用。

我已经用谷歌搜索了它,但我找不到任何解决方案

谢谢你的帮助

赛克

0 投票
1 回答
2755 浏览

c# - Powershell Cmdlet 缺少程序集 Google Api

仅在尝试创建 Powershell Cmdlet 时出现问题。我可以在控制台应用程序的流程记录中执行相同的代码。想法是 App.config 没有重定向程序集,但没有取得太大的成功。我使用 nuget 包来引用 Google-api-dotnet-client

示例代码在这里
http://tinyurl.com/mbx3yle

错误
http://i.imgur.com/xiEjwAR.png

psTest.cs

应用程序配置

融合日志

将 System.Net.Http.Primitives 版本 2.1.10 和 1.5 添加到 GAC

0 投票
0 回答
1830 浏览

c# - A Task was Canceled - ResumeableUpload.cs: line 362

For almost the past 24 hours, I have been receiving TaskCanceledExceptions as the result of calls to ResumeableUpload's UploadAsync. Uploads are failing probably 90% of the time. I am uploading videos to youtube.

I was using an earlier version of the google-apis (1.4) so I tried upgrading to the latest nuget packages for 1.5, but the issue is unchanged.

Any idea what might be occurring? I am perplexed as I haven't changed my code in sometime...

0 投票
1 回答
3428 浏览

c# - 具有程序集依赖项的 NGen 错误

我有一个显然不是新问题,但我似乎仍然找不到答案的问题。

我正在使用 Google 的 Analytics API for .NET,并且在尝试让程序集很好地协同工作时遇到了困难。通过 Visual Studio 2012 构建时,我没有遇到任何构建错误。但是,当我开始使用 NGen 预编译项目时,我看到很多错误的程序集引用。

我正在使用 MVC 4、Visual Studio 2012 和最新的 Google.Apis 包(截至目前为 1.5.0.1-beta)。

我在相关项目中安装的 .dll / 版本是:

以下是我在 NGen 的输出中发现的错误:

Failed to load dependency System.Net.Http.Primitives of assembly Google.Apis, Version=1.4.0.28227, Culture=neutral, PublicKeyToken=null because of the following error : The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Failed to load dependency System.Web.Mvc of assembly DotNetOpenAuth, Version=4.0.0.11165, Culture=neutral, PublicKeyToken=2780ccd10d57b246 because of the following error : The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Failed to load dependency log4net of assembly DotNetOpenAuth, Version=4.0.0.11165, Culture=neutral, PublicKeyToken=2780ccd10d57b246 because of the following error : The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

这是我在该项目的 web.config 中的内容:

我相信其中大部分是在我使用 NuGet 安装 Google.Apis 包时构建的,但我不明白为什么程序集绑定重定向不能防止 NGen 出现这些错误。

如果有人能帮助我指出正确的方向,我将不胜感激!谢谢!

0 投票
2 回答
677 浏览

asp.net - Google Analytics V3 ASP.Net API beta 1.5 OAuth2 错误

我正在使用带有服务帐户的 Google API 的最新 beta 1.5 (1.5.0.28991),并且在进行身份验证时在 AssertionFlowClient 行上遇到此错误:

找不到方法:'无效 DotNetOpenAuth.OAuth2.ClientBase..ctor(DotNetOpenAuth.OAuth2.AuthorizationServerDescription, System.String, System.String)'。

DotNetOpenAuth V4.3.1.13153

我对此感到头疼 - 任何指示都会受到赞赏。

0 投票
2 回答
821 浏览

c# - Google .net API v3 类 OAuth2LeggedAuthenticator 等效项

我目前正在开发一个 C# MVC 网站,该网站将使用 Google 的日历 API,但我在整理 OAuth 2.0 时遇到了麻烦。

我正在关注这个 stackoverflow问题,它引用OAuth2LeggedAuthenticator了最新的 NuGet 包中没有出现的类

Install-Package Google.Apis.Calendar.v3 -Pre

Install-Package Google.Apis.Authentication -Pre

这是因为 Google 已经转移到 OAuth 2 身份验证模式,那么有没有办法使用最新版本的 .net API 进行 2 腿身份验证?

干杯

0 投票
3 回答
5595 浏览

.net - 如何使用服务帐户向 Google v3 api 进行身份验证

我在这里遵循了示例代码: https ://code.google.com/p/google-api-dotnet-client/wiki/OAuth2#Service_Accounts

授权失败:DotNetOpenAuth.Messaging.ProtocolException:发送直接消息或获取响应时发生错误。

内部异常是 System.Net.WebException: The remote server returned an error: (400) Bad Request。响应正文为空,响应 URI 为https://accounts.google.com/o/oauth2/token

在下面的响应中,您将看到特定错误是 invalid_grant。

这是我的代码:

证书和 ServiceAccountId 正确。我进行了三次检查,并且已经重新生成了证书。Google 日历 API 在 API 控制台中为用于创建服务帐户的 google 开发人员帐户打开。此帐户不属于 Google Apps 域。

我还使用指定的 AssertionFlowClient 的 ServiceAccountUser 属性对此进行了测试。我现在认为这是必需的 - 在我使用手动创建的 JWT 成功测试 CalendarService 时(请参阅下面的 OAuth 令牌的手动创建工作),当 prn 属性不包含在尝试创建令牌时,我收到 404 错误声明(即不包括 ServiceAccountUser)。

Google Apps 域配置

在 Google Apps 域中,我已授予此服务帐户访问日历的权限。

客户名称:[snip].apps.googleusercontent.com

API 范围:

已安装的 NuGet 包

  • Google.Apis(1.5.0-beta)
  • Google.Apis.Calendar.v3 (1.5.0.59-beta)
  • Google.Apis.Authentication(1.5.0-beta)

请求和响应

仔细检查,断言似乎是正确的,在这里解码:


手动创建 OAuth 令牌作品

为了确认我的设置正确,我使用 google-oauth-jwt 手动创建了一个令牌(此处:https ://github.com/extrabacon/google-oauth-jwt )。我能够使用上面代码中使用的相同属性成功创建令牌。一旦我创建了令牌并在自定义 IAuthenticator 中使用它,我就可以成功地从目标 Google Apps 域中的用户日历中检索事件。因此,如果您想知道,可以使用服务帐户访问日历!

这是 IAuthenticator 实现,它只是添加了 Authorization 标头: