找不到类型或命名空间名称“IAuthorizationState”

时间:2013-12-13 07:18:53

标签: c# asp.net-mvc-4 google-oauth

我正在使用带有MVC4的Google-Auth Calendar API,我遇到了这个错误: "类型或命名空间名称' IAuthorizationState'找不到(你错过了使用指令或汇编引用吗?)" 这是我的命名空间:

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;
    }

我不知道我在这里失踪了什么。我已经包含了一切。请帮助我。

1 个答案:

答案 0 :(得分:2)

删除后再次尝试添加引用。如果你正在使用tfs或任何其他存储库,那么就有可能导致参考文献被破坏。