我有一个 ASP.NET MVC 应用程序,我正在尝试将 DotNetOpenAuth 用于我的 Google OAuth。我正在使用示例中的 GoogleConsumer 类,并尝试执行身份验证的第一步。下面的代码与提供的 WebForms 应用程序中的代码基本相同,只是在 MVC 控制器中:
public string Authenticate()
{
GoogleTokenManager tokenManager = new GoogleTokenManager(ConsumerKey, ConsumerSecret);
WebConsumer webConsumer = new WebConsumer(GoogleConsumer.ServiceDescription, tokenManager);
GoogleConsumer.RequestAuthorization(webConsumer, GoogleConsumer.Applications.Gmail);
return "";
}
当我向控制器发出 AJAX 请求时,代码会执行,但我从未被重定向到 Google 页面进行身份验证。