运行下面的代码永远不会从执行函数返回。我的个人 Gmail 帐户上有一个私人日历,已与developer.gserviceaccount.com 帐户共享。
查看 API 管理器,用法/引用显示我已经使用过甚至点击了该 API。
任何想法表示赞赏。
using System.Security.Cryptography.X509Certificates;
using System.Web;
using Google.Apis.Calendar.v3;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
public class GoogleLoginWithServiceAccount
{
public string getEventList()
{
var GoogleOAuth2CertificatePath = HttpContext.Current.Server.MapPath("~/xx/xx.p12");
var GoogleOAuth2EmailAddress = "[email protected]";
var GoogleOAuth2PrivateKey = "notasecret";
var certificate = new X509Certificate2(GoogleOAuth2CertificatePath,
GoogleOAuth2PrivateKey, X509KeyStorageFlags.Exportable);
var credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(GoogleOAuth2EmailAddress)
{
//User = GoogleAccount,
Scopes = new string[] { CalendarService.Scope.Calendar }
}.FromCertificate(certificate));
// Create the service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Testing"
});
var listRequest = service.CalendarList.List();
return listRequest.Execute().ToString();
}
}
我仍然遇到这个问题。我创建了一个简单的应用程序来重现这一点,有人有什么想法吗? dropbox.com/s/g45xcta7ii3hj51/GoogleTestWeb.zip?dl=0
该问题在中进行了更详细的描述https://github.com/google/google-api-dotnet-client/issues/606。看来我们目前在 1.9.3 中有一个错误,已在 github 存储库中修复(修复本身位于https://github.com/google/google-api-dotnet-client/pull/612).
计划在未来几周内发布新版本,敬请期待;http://google-api-dotnet-client.blogspot.com/.
如果同时您想亲自体验和测试它,您可以将 GitHub 中的项目与日历服务结合使用。您最好从以下位置下载日历服务https://developers.google.com/resources/api-libraries/download/calendar/v3/csharp以避免绑定重定向。我在 #606 本身中解释了你必须做什么。
更新(12 月 15 日):1.10.0 的新 NuGet 包已可用,请在以下位置了解更多信息:http://google-api-dotnet-client.blogspot.com/2015/12/announcing-release-of-1100.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)