我想使用 oauth 和 facebook、twitter、google 等实现基于角色的登录。它只会使用 oauth 并且会有一个角色系统。不是具有通常注册和登录的默认模板。似乎 dot net open auth 将有助于初始的东西,但我找不到使用或扩展它的好例子。有人可以解释如何从头开始使用 dotnet open auth 以及如何使用它获取额外信息吗?
问问题
10905 次
2 回答
10
- 启动 Visual Studio 2012
- 使用 Internet 模板创建一个新的 ASP.NET MVC 4 应用程序
- 打开
~/App_Start/AuthConfig.cs
文件 - 通过将您的客户端密钥和密码放入相应的提供程序来取消注释您要使用的提供程序
有关 OAuth 集成的更多信息,我邀请您前往该DotNetOpenAuth
站点,浏览documentation
、下载并使用示例。
于 2013-01-27T17:55:37.203 回答
0
打开 ~/App_Start/AuthConfig.cs 文件并使用它
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Web.WebPages.OAuth;
namespace MVCTemplateProject
{
public static class AuthConfig
{
public static void RegisterAuth()
{
OAuthWebSecurity.RegisterMicrosoftClient(
clientId: "code",
clientSecret: "code");
//OAuthWebSecurity.RegisterTwitterClient(
// consumerKey: "",
// consumerSecret: "");
//OAuthWebSecurity.RegisterFacebookClient(
// appId: "",
// appSecret: "");
OAuthWebSecurity.RegisterLinkedInClient("code", "code");
OAuthWebSecurity.RegisterGoogleClient();
}
}
}
于 2013-01-27T17:57:02.627 回答