I am Google Auth api Calendar in .net. I have copied the code from this link:Refresh Token Expiration time Google calendar Could not load type 'Google.Apis.Requests.IErrorResponseHandler' from assembly 'Google.Apis, Version=1.6.0.16897, Culture=neutral, PublicKeyToken=null'
Here is my code:
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;
}