【发布时间】:2013-12-12 10:45:24
【问题描述】:
我是 .net 中的 Google Auth api 日历。我已经从这个链接复制了代码:Refresh Token Expiration time Google calendar 无法从程序集“Google.Apis, Version=1.6.0.16897, Culture=neutral, PublicKeyToken=null”加载类型“Google.Apis.Requests.IErrorResponseHandler”
这是我的代码:
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;
}
【问题讨论】:
-
嗨!你能在哪里解决这个问题?我也有同样的问题。谢谢
-
还没有。实际上我想保存刷新令牌,以便在我进行以下调用时可以获得未过期的访问令牌
-
好的,但是没有令牌不应该这样工作。我的意思是,您是否使用密钥(p.12 - 文件)和凭据登录到谷歌 API?我的代码在控制台应用程序中运行良好,但是当我在 Mvc 中实现代码时,我遇到了这个问题。这是我的代码:stackoverflow.com/questions/22144085/…
标签: c# asp.net-mvc-3 oauth oauth-2.0 google-calendar-api