我在.NET谷歌验证API日历。 我从这个链接复制代码: 刷新令牌到期时间谷歌日历未能从程序集加载类型“Google.Apis.Requests.IErrorResponseHandler“Google.Apis,版本= 1.6.0.16897,文化=中立,公钥=空”
这里是我的代码:
private CalendarService CreateService(string token)
{
//KeyValuePair<string, string> credentials = Ninject.Web.Common.Get3LOCredentials();
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, this.clientID, this.ClientSecret);
//provider.ClientIdentifier = clientID;
//provider.ClientSecret = clientSecret;
var auth = new Google.Apis.Authentication.OAuth2.OAuth2Authenticator<NativeApplicationClient>(provider, (p) => GetAuthorization(provider, token));
CalendarService service = new CalendarService(new BaseClientService.Initializer()
{
Authenticator = auth,
ApiKey = ConfigurationManager.AppSettings[this.APIkey].ToString(),
GZipEnabled = false
});
return service;
}
private static IAuthorizationState GetAuthorization(NativeApplicationClient arg, String Refreshtoken)
{
IAuthorizationState state = new AuthorizationState(new[] { CalendarService.Scopes.Calendar.GetStringValue() });
state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
state.RefreshToken = Refreshtoken;
return state;
}