gpt4 book ai didi

c# - 找不到类型或命名空间名称 'IAuthorizationState'

转载 作者:行者123 更新时间:2023-11-30 17:01:52 24 4
gpt4 key购买 nike

我在 MVC4 中使用 Google-Auth Calendar API,我遇到了这个错误:“找不到类型或命名空间名称‘IAuthorizationState’(是否缺少 using 指令或程序集引用?)”这是我的命名空间:

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 和刷新 token :

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

而且我不知道我在这里缺少什么。我已经包括了一切。请帮助我。

最佳答案

删除后尝试重新添加引用。如果您使用的是 tfs 或任何其他存储库,则可能存在损坏的引用。

关于c# - 找不到类型或命名空间名称 'IAuthorizationState',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20561113/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com