问题标签 [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.
c# - 在不查询特定 Google 服务的情况下对用户进行身份验证
我想使用 .NET 客户端 API 对用户进行身份验证并授权 Web 服务器应用程序 - 使用Google.Apis.*
来自 NuGet 的包。
我查看了示例并了解了 NativeApplicationClient 和 WebServerClient 是如何在那里使用的。我特别看了一下“Tasks.ASP.NET.SimpleOAuth2”示例。但是我想要实现的是在不调用我最终要使用的 Google 服务的情况下执行身份验证,而在示例中,身份验证是最初设置的,并在对服务的第一个请求时“自动”调用。
假设我的应用想要使用日历。所以我想使用 SDK 来:
- 生成我将传递给我的客户端的身份验证 URL(一种 OutgoingWebResponse)
- 获得重定向后验证代码并获取访问令牌
但在这一步没有对日历服务进行任何实际调用。
任何指导将不胜感激。谢谢
c# - Google Directory API - 使用服务帐户时出现错误 400
我正在使用 Directory API 的最新 Beta,在尝试获取用户列表时,我得到以下信息:
“远程服务器返回错误:(400)错误请求。”
我能够从 API Explorer ( https://developers.google.com/apis-explorer/#p/admin/directory_v1/directory.users.list ) 执行此功能,并且我拥有所有适当的权限和范围集。
C#代码如下:
google-api-dotnet-client - Google .NET 客户端 Youtube v3 错误
尝试将视频上传到我的 youtube 频道时出现以下错误:
System.ArgumentException: Precondition failed.: !string.IsNullOrEmpty(authorization.RefreshToken)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) at Microsoft.Runtime。 CompilerServices.TaskAwaiter.ValidateEnd(Task task) 在 Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult()
at Google.Apis.Upload.ResumableUpload
1.d__0.MoveNext() 在 c:\code.google.com\google-api-dotnet-client\default_3\Tools\Google.Apis。 Release\bin\Debug\output\default\Src\GoogleApis\Apis[媒体]\Upload\ResumableUpload.cs:356行
编码:
任何想法为什么会发生这种情况?
我正在使用 Google.Apis DotNetOpenAuth 版本的 1.5.0.28972 版本:4.0.0.11165
c# - Google Analytics GetRequest 错误:System.Net 版本 2.0.5.0 需要查看 HttpStatusCode
我正在使用 Google Analytics Core Reporting API。我可以使用这样的代码成功运行我的请求。
所以在我的responseData
对象中,我拥有我需要的所有数据。但我也需要知道我的请求何时有错误。所以我需要抓住一个GoogleApiException
有HttpStatusCode
属性的。此 Http 状态代码将让我知道我是否已达到每天的请求配额,以便我可以在 24 小时后继续接收信息。但是当我遇到这样的异常时:
我收到一条错误消息:
类型“System.Net.HttpStatusCode”在未引用的程序集中定义。您必须添加对程序集“System.Net,Version=2.0.5.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e,Retargetable=Yes”的引用。
而且我似乎无法通过 NuGet 或其他地方找到该库。是否有另一种获取状态代码的方法,或者是否有人在某处拥有图书馆?
c# - 仅在必要时刷新访问令牌
根据此处发布的上一个问题,我正在尝试从服务器应用程序使用日历服务。
我“自己”管理身份验证流程,并将用户的访问令牌和刷新令牌存储在数据库中。现在我想我可以使用 .NET 客户端示例中显示的方法来使用CalendarService
. 但是我仍然想知道该IAuthorizationState GetAuthorization(WebServerClient client)
方法的最佳实现是什么,以便仅在需要时请求刷新访问令牌。我当前的幼稚实现每次都会刷新令牌:
...但我确信有更聪明的方法可以做到这一点!
提前致谢。
google-oauth - ArgumentException: Precondition failed.: !string.IsNullOrEmpty(authorization.RefreshToken) with Service Account for Google Admin SDK Directory access
I'm trying to access the Google Directory using a Service Account. I've fiddled with the DriveService example to get this code:
When I run it, I get
I'm going round in circles in the Google documentation. The only stuff I can find about RefreshTokens seems to be for when an individual is authorizing the app and the app may need to work offline. Can anyone help out or point me in the direction of the documentation that will, please.
powershell - 'DotNetOpenAuth.Logger' 的类型初始化程序引发异常
我的目标是从 PowerShell 调用 Google Admin SDK Directory 更新。我从一个工作的 .NET 应用程序开始,并将其转换为一个类库(我测试过——它可以工作)。我将其加载到模块清单中
我的 Get-GoogleSDKUser 函数 New-Objects 我的类并在其上调用 GetUser。我得到:
我试过为 log4net 添加一个配置文件,它产生了一个空的日志文件,但这没有帮助。
注意:为了做到这一点,我必须添加
到 powershell_ise.exe.config 以防止错误:
“无法加载文件或程序集 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一。系统找不到指定的文件。”
这远非理想。
编辑
PowerShell-calling-my-DLL 版本的 InnerException 是:
无法加载文件或程序集 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' 或其依赖项之一。该系统找不到指定的文件。
花了一些时间才找到 innerException。我有一些雪貂,并找到了使用 Fuslogvw 的建议,所以我尝试了。我关闭并重新打开 PowerShell,启动 Fusion Log Viewer(这是我第一次使用它)并找到三个 log4net 条目。说明如下:
- log4net
- log4net,版本=1.2.12.0,文化=中性,PublicKeyToken=669e0ddf0bb1aa2a
- log4net,版本=1.2.10.0,文化=中性,PublicKeyToken=1b44e1d426115821
当我打开它们时,前两个有“手术成功”。作为文本的第二行。第三个有'操作失败。绑定结果:hr = 0x80070002。该系统找不到指定的文件。'
当我深入研究该日志时,我发现:
我尝试再次从 Visual Studio 运行它。fuslogvw 中也有三个条目,第三个有相同的错误。但是 VS 输出中没有任何内容表明存在问题。
c# - 使用在 Gdrive 中与我共享的文件 ID 更新文件,
C# 应用程序
我需要使用文件 ID 更新在 Gdrive 中共享的文件。
代码:
抛出错误:找不到文件。
google-api-dotnet-client - 有人可以创建带有推送通知的工作(.net 4.5.1)Google 日历示例吗
谷歌示例不起作用。我找不到工作的。文档是无用的。
框架.net 4.5.1
nuget
- DotNetOpenAuth 5.0.0-alpha1
- Google.Apis.Calendar.v3 -版本 1.5.0.65-beta
- Google.Apis.Authentication.OAuth2 -版本 1.2.4696.27634
第一行第一个错误
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description "id", "key");
模块 dotnetopenoauth, 版本=4.0.0.111 应该被引用
我已经尝试了很多框架和在线示例,但也可以工作。
对不起,我的英语不好。