Google Calendar API - 未从执行中返回()C# [英] Google Calendar API - Not Returning From Execute() C#

查看:105
本文介绍了Google Calendar API - 未从执行中返回()C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行下面的代码永远不会从Execute函数返回。我在我的个人gmail帐户上有一个私人日历,我已经与developer.gserviceaccount.com帐户共享。



查看API管理器,用法/引号显示我已经使用过,甚至还打了API。



任何想法都可以使用。

 使用System.Security.Cryptography.X509Certificates; 
使用System.Web;
使用Google.Apis.Calendar.v3;
使用Google.Apis.Auth.OAuth2;
使用Google.Apis.Services;

public class GoogleLoginWithServiceAccount
{
public string getEventList()
{
var GoogleOAuth2CertificatePath = HttpContext.Current.Server.MapPath(〜/ xx / xx.p12\" );
var GoogleOAuth2EmailAddress =xx-xxxx@developer.gserviceaccount.com;
var GoogleOAuth2PrivateKey =notasecret;

var certificate = new X509Certificate2(GoogleOAuth2CertificatePath,
GoogleOAuth2PrivateKey,X509KeyStorageFlags.Exportable);
var credential = new ServiceAccountCredential(
)ServiceAccountCredential.Initializer(GoogleOAuth2EmailAddress)
{
// User = GoogleAccount,
Scopes = new string [] {CalendarService.Scope .Calendar}
} .FromCertificate(certificate));

//创建服务。
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer =凭证,
ApplicationName =测试
});
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中有一个bug,它已在github存储库中修复(修复本身位于 https://github.com/google/google-api-dotnet-client/pull/612 )。



新版本计划在未来几周内发布,敬请关注; http://google-api-dotnet-client.blogspot.com/



如果您希望自己玩并测试它,则可以使用GitHub中的项目和日历服务。您最好从 https://开发人员处下载日历服务.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


Running the code below never returns from the Execute function. I have a private calendar on my personal gmail account that I have shared with the developer.gserviceaccount.com account.

Looking at the API Manager, the usage/quotes show that I have used or even hit the api yet.

Any thoughts appreciated.

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 = "xx-xxxx@developer.gserviceaccount.com";
        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();        
    }    
}

I'm still running into this issue. I've created a simple app to reproduce this, anybody have any thoughts? dropbox.com/s/g45xcta7ii3hj51/GoogleTestWeb.zip?dl=0

解决方案

The problem is described more in details in https://github.com/google/google-api-dotnet-client/issues/606. It seems that we currently have a bug in 1.9.3, which is fixed in the github repository (The fix itself is in https://github.com/google/google-api-dotnet-client/pull/612).

A new release is planned to be in the next few weeks, so stay tuned; http://google-api-dotnet-client.blogspot.com/.

If meantime you want to play and test it yourself you can use the projects in GitHub with the Calendar Service. It's better for you to download the Calendar Service from https://developers.google.com/resources/api-libraries/download/calendar/v3/csharp to avoid binding redirects. I explained what you have to do in #606 itself.


Update (Dec 15th): New NuGet packages for 1.10.0 are available, read more about it at: http://google-api-dotnet-client.blogspot.com/2015/12/announcing-release-of-1100.html

这篇关于Google Calendar API - 未从执行中返回()C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆