Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从Google calendar v3测试版迁移到v3 1.8.1.820_C#_Asp.net_Calendar_Google Calendar Api_Google Api Dotnet Client - Fatal编程技术网

C# 从Google calendar v3测试版迁移到v3 1.8.1.820

C# 从Google calendar v3测试版迁移到v3 1.8.1.820,c#,asp.net,calendar,google-calendar-api,google-api-dotnet-client,C#,Asp.net,Calendar,Google Calendar Api,Google Api Dotnet Client,我已经将我的asp.net应用程序从Google calendar V2迁移到V3 Beta版,但现在他们已经发布了新的DLL,版本为1.8.1.820,所以任何人都可以在这方面帮助我如何转换。在我的V3测试版中,我使用了以下代码 private CalendarService CreateService(string token) { KeyValuePair<string, string> credentials = Common.Get3LOCredentials()

我已经将我的asp.net应用程序从Google calendar V2迁移到V3 Beta版,但现在他们已经发布了新的DLL,版本为1.8.1.820,所以任何人都可以在这方面帮助我如何转换。在我的V3测试版中,我使用了以下代码

 private CalendarService CreateService(string token)
{
    KeyValuePair<string, string> credentials = Common.Get3LOCredentials();
    var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
    provider.ClientIdentifier = credentials.Key;
    provider.ClientSecret = credentials.Value;
    var auth = new Google.Apis.Authentication.OAuth2.OAuth2Authenticator<NativeApplicationClient>(provider, (p) => GetAuthorization(provider, token, credentials.Key, credentials.Value));
    CalendarService service = new CalendarService(new BaseClientService.Initializer()
    {
        Authenticator = auth,
        ApiKey = ConfigurationManager.AppSettings["APIkey"].ToString(),
        GZipEnabled = false
    });
    provider = null;
    return service;
}
private CalendarService CreateService(字符串令牌)
{
KeyValuePair credentials=Common.get3Locaredentials();
var provider=new NativeApplicationClient(GoogleAuthenticationServer.Description);
provider.ClientIdentifier=credentials.Key;
provider.ClientSecret=credentials.Value;
var auth=new Google.api.Authentication.OAuth2.OAuth2Authenticator(provider,(p)=>getauthentication(provider,token,credentials.Key,credentials.Value));
CalendarService=新的CalendarService(新的BaseClientService.Initializer()
{
Authenticator=auth,
ApiKey=ConfigurationManager.AppSettings[“ApiKey”].ToString(),
GZipEnabled=false
});
provider=null;
回程服务;
}
在新版本中,他们没有本地应用程序客户端类,也没有太多的功能。所以,请提供一些文档,如果有人有,因为谷歌没有提供一个好的ASP.NET开发人员的文档

这是我正在使用的新版谷歌日历的代码:-

private CalendarService CreateService(string token)
{
    GoogleAuthorizationCodeFlow flow = null;
    var assembly = Assembly.GetExecutingAssembly();       
    KeyValuePair<string, string> credentials = Common.Get3LOCredentials();
    UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = credentials.Key, ClientSecret = credentials.Value }, new[] { "https://www.googleapis.com/auth/calendar" }, "user", CancellationToken.None, new FileDataStore("Calendar.Sample.Store")).Result;
    var service = new CalendarService(new BaseClientService.Initializer()
    {
        HttpClientInitializer = credential,
        ApplicationName = "Calendar API Sample",
    });
    return service;
}
private CalendarService CreateService(字符串令牌)
{
GoogleAuthorizationCodeFlow=null;
var assembly=assembly.getExecutionGassembly();
KeyValuePair credentials=Common.get3Locaredentials();
UserCredential credential=GoogleWebAuthorizationBroker.AuthorizationAsync(新的ClientSecrets{ClientId=credentials.Key,ClientSecret=credentials.Value},新的[]{”https://www.googleapis.com/auth/calendar},“user”,CancellationToken.None,新文件数据存储(“Calendar.Sample.Store”).Result;
var service=new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer=凭证,
ApplicationName=“日历API示例”,
});
回程服务;
}

首先,日历API不是beta版,它在这里提供-

在过去的几个月里,该库处于测试阶段,我们努力提高它的质量,并消除DotNetOpenAuth中的依赖性。看看公告博客-,这里解释了所有的变化


从1.8.1版开始,我们不会有任何不兼容的更改,因为库已经达到GA(通用性)。所有OAuth 2.0文档可在以下位置获得:。请看一下这一页,让我们知道是否有遗漏。具体地说,你可以在一个或一个

中看一看。难道你不喜欢每个版本与上一个版本相比都有重大的突破性变化吗。去谷歌!谢谢你的回复。我已尝试此部分,但我遇到异常“一个或多个异常”请检查我已更新的问题,在上面的代码中,我得到的CalendarService.Scope.Calendar为null,我不确定为什么我会将此设置为null,以及我需要在哪里指定我们在第一次身份验证时获得的accessToken,因为我没有看到我们在哪里指定标记。我认为Google developer上提到的代码是针对已安装的应用程序的,但我正在web应用程序中集成,因此需要在中指定accessToken每个请求,那么在哪里可以使用API在请求中指定AccessToken呢。我对它进行了研究,但只得到了旧代码。