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

3
我正在使用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;
    }

我不知道我在这里缺少了什么。我已经为此包含了所有内容。请帮助我。


有时候您需要在项目中添加一个引用,请尝试使用“添加引用”。 - Usman Waheed
我已经添加了所有命名空间的引用。 - Zaid Iqbal
1个回答

2

在删除引用后,请尝试重新添加引用。如果您正在使用TFS或其他存储库,则有可能出现损坏的引用。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接