我正在使用MVC4和Google-Auth日历API,但是我遇到了以下错误:
“The type or namespace name 'IAuthorizationState' could not be found (are you missing a using directive or an assembly reference?)”
这是我的命名空间:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Web.Mvc;
using HRBC.Areas.Admin.Models;
using HRBC.Controllers;
using HRBC.Models;
using HRBC.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Web.Script.Serialization;
using System.Xml;
using System.Diagnostics;
using System.Text;
using DotNetOpenAuth.OAuth2;
using System.IO;
//using DotNetOpenAuth.OAuth;
//using Google.Apis.Plus.v1;
using Google.Apis.Util;
using Google.Apis;
using Google.Apis.Services;
using Google.Apis.Calendar;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Authentication;
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using System.Security.Cryptography;
using System.Configuration;
我正在使用以下代码调用API并刷新令牌:
private static CalendarService CreateService(string token)
{
//KeyValuePair<string, string> credentials = Ninject.Web.Common.Get3LOCredentials();
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, "CLient ID", "Client Secret");
//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["APIkey"].ToString(),
GZipEnabled = false
});
return service;
}
private static IAuthorizationState GetAuthorization(NativeApplicationClient arg, String Refreshtoken)
{
IAuthorizationState state = new AuthorizationState(new[] { CalendarService.Scope.Calendar });
state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
state.RefreshToken = Refreshtoken;
return state;
}
我不知道我在这里缺少了什么。我已经为此包含了所有内容。请帮助我。