【问题标题】:OAuth with Microsoft not working correctlyMicrosoft 的 OAuth 无法正常工作
【发布时间】:2012-10-19 06:52:30
【问题描述】:
【问题讨论】:
标签:
oauth
microsoft-live-connect
【解决方案1】:
简答:
1) 更新您的主机文件,添加行:“127.0.0.1 mynewApplication.test”
2) 在 manage.dev.live.com 中将“重定向域”设置为 http://mynewApplication.test:[PORT]
3) 在本地运行您的应用程序,确保您的浏览器中有 http://mynewApplication.test:[PORT]
4) 使用 Microsoft 登录
这对我来说很好。
长答案:
看起来您必须在 Ms 应用程序管理工具中将“重定向域”指定为某个唯一的域名,如果您在本地测试您的应用程序,您必须在主机文件中维护该域名。他们不再允许设置像“localtest.me”这样的共享域名。
如果您查看 fiddler,您会看到 MVC 将引用 URL(您在浏览器中看到的当前 URL)添加到 oauth 请求。因此,当您发送将您重定向到 Microsoft oauth 的单击按钮时,请确保您的浏览器从在 App Redirect 域中注册的相同域名加载当前页面。
【解决方案2】:
步骤:
- 在Windows Live application management site注册您的应用程序,请参阅Registering Your Application with Windows Live
- 在 API 配置下,输入您的根域,例如:
www.yourdomain.com
- 在 API 配置下,输入您的应用程序 URL。不要忘记包括:Account/RegisterExternalLogin
www.yourdomain.com/YourApp/Account/RegisterExternalLogin
-
编辑 AuthConfig.vb,取消注释 OpenAuth.AuthenticationClients.AddMicrosoft 并从 Windows Live 应用程序管理站点 复制您的 clientId 和 clientSecret
OpenAuth.AuthenticationClients.AddMicrosoft(
clientId:="0000000000000",
clientSecret:="x0-0000000000000000")
在 www.yourdomain.com/YourApp 中发布您的应用程序
PS。不要忘记在 Web.config (DefaultConnection)
中更新您的 connectionString