C# Google Calendar.NETAPI V3域范围的委派
我在用 asp.net 4.0、Google calendar api V3以及windows 2003 R2 Web服务器和IIS 6.0环境,我们拥有自己的许可Google域 我的应用程序需要访问很多人的谷歌日历和添加/删除/更新事件,我们之前使用了V2,并且正在使用消费者密钥和消费者机密。目前,我的代码已迁移到V3版本,并且可以正常工作,因为我使用的是使用API密钥和加密密钥文件的服务帐户类型。但是我的客户不是很感兴趣,他们正在寻找类似OAuth2.0版本V2的身份验证 那么,我的问题是,除了V3的服务帐户之外,最好的方法是什么,来为大量用户执行所有操作,这些用户应该使用像V2一样的一次性身份验证 谢谢,C# Google Calendar.NETAPI V3域范围的委派,c#,oauth-2.0,google-calendar-api,C#,Oauth 2.0,Google Calendar Api,我在用 asp.net 4.0、Google calendar api V3以及windows 2003 R2 Web服务器和IIS 6.0环境,我们拥有自己的许可Google域 我的应用程序需要访问很多人的谷歌日历和添加/删除/更新事件,我们之前使用了V2,并且正在使用消费者密钥和消费者机密。目前,我的代码已迁移到V3版本,并且可以正常工作,因为我使用的是使用API密钥和加密密钥文件的服务帐户类型。但是我的客户不是很感兴趣,他们正在寻找类似OAuth2.0版本V2的身份验证 那么,我的问题是,
MVM您可以使用日历API V3和Web授权。在这种情况下,网页将重定向到用户同意屏幕,然后最终用户应授权请求
using System;
using System.Threading;
using System.Threading.Tasks;
using Google;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Services;
namespace Calendar.Sample
{
class Program
{
static void Main(string[] args)
{
UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "CLIENT_ID_HERE",
ClientSecret = "CLIENT_SECRET_HERE",
},
new[] { CalendarService.Scope.Calendar },
"user",
CancellationToken.None).Result;
// Create the service.
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Calendar API Sample",
});
...
}
}
}