1

我正在确定一个框架,用于构建具有良好客户端库(没有很多)的本地 OAuth (2.0) Provider,乍一看,DotNetOpenAuth 似乎很理想,我很兴奋并想尝试这些示例.

我花了几天时间摆弄示例和源代码本身,但我仍然无法找到让 OAuth2\AuthorizationServer 示例正常工作的方法。示例适用于所有其他外部提供程序。我浏览了许多帖子以找出理想的设置、输入、设置以通过初始登录屏幕,但我没有运气。

有人可以分享启动和运行 OAuth2\AuthorizationServer 示例要遵循的初始步骤。包括数据库设置。我尝试单步执行代码但丢失了它。

珍惜你的时间。如果我能清楚地理解这些步骤,我很乐意记录这些步骤。我认为该框架非常好,但缺乏文档。再次感谢!

这是我得到的错误,

DotNetOpenAuth.Messaging.ProtocolException:未找到 OpenID 端点。---> System.InvalidOperationException:序列不包含任何元素

我使用依赖方 URI 作为输入,http:// localhost:59722 / http:// localhost:59722 /SampleWcf2.aspx

以及完整的堆栈跟踪,

DotNetOpenAuth.Messaging.ProtocolException: No OpenID endpoint found. ---> System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) in d:\Temp\dotnetopenid\src\DotNetOpenAuth.OpenId.RelyingParty\OpenId\RelyingParty\OpenIdRelyingParty.cs:line 352
   --- End of inner exception stack trace ---
   at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) in d:\Temp\dotnetopenid\src\DotNetOpenAuth.OpenId.RelyingParty\OpenId\RelyingParty\OpenIdRelyingParty.cs:line 354
   at OAuthAuthorizationServer.Controllers.AccountController.LogOn(LogOnModel model, String returnUrl) in D:\Temp\dotnetopenid\samples\OAuthAuthorizationServer\Controllers\AccountController.cs:line 40
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
   at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


2012-06-15 16:08:03,490 (GMT+10) [16] DEBUG DotNetOpenAuth.Http - HTTP GET http://localhost:59722/SampleWcf2.aspx
2012-06-15 16:08:03,498 (GMT+10) [16] DEBUG DotNetOpenAuth.Yadis - HTML discovery failed to find any endpoints.
2012-06-15 16:08:03,498 (GMT+10) [16] INFO  DotNetOpenAuth.Yadis - Performing discovery on user-supplied identifier: http://localhost:59722/SampleWcf2.aspx
2012-06-15 16:08:03,498 (GMT+10) [16] DEBUG DotNetOpenAuth.Yadis - Filtering and sorting of endpoints did not affect the list.
2012-06-15 16:08:03,578 (GMT+10) [16] ERROR DotNetOpenAuth.OAuthAuthorizationServer - An unhandled exception occurred in ASP.NET processing: DotNetOpenAuth.Messaging.ProtocolException: No OpenID endpoint found. ---> System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) in d:\Temp\dotnetopenid\src\DotNetOpenAuth.OpenId.RelyingParty\OpenId\RelyingParty\OpenIdRelyingParty.cs:line 352
   --- End of inner exception stack trace ---
   at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) in d:\Temp\dotnetopenid\src\DotNetOpenAuth.OpenId.RelyingParty\OpenId\RelyingParty\OpenIdRelyingParty.cs:line 354
   at OAuthAuthorizationServer.Controllers.AccountController.LogOn(LogOnModel model, String returnUrl) in D:\Temp\dotnetopenid\samples\OAuthAuthorizationServer\Controllers\AccountController.cs:line 40
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
   at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
DotNetOpenAuth.Messaging.ProtocolException: No OpenID endpoint found. ---> System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) in d:\Temp\dotnetopenid\src\DotNetOpenAuth.OpenId.RelyingParty\OpenId\RelyingParty\OpenIdRelyingParty.cs:line 352
   --- End of inner exception stack trace ---
   at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.CreateRequest(Identifier userSuppliedIdentifier, Realm realm, Uri returnToUrl) in d:\Temp\dotnetopenid\src\DotNetOpenAuth.OpenId.RelyingParty\OpenId\RelyingParty\OpenIdRelyingParty.cs:line 354
   at OAuthAuthorizationServer.Controllers.AccountController.LogOn(LogOnModel model, String returnUrl) in D:\Temp\dotnetopenid\samples\OAuthAuthorizationServer\Controllers\AccountController.cs:line 40
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
   at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
   at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
   at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

强文本

4

2 回答 2

1

听起来您将 OAuth 2.0 授权服务器与 OpenID 2.0 提供者混淆了。他们完全不同。当“登录”到授权服务器示例时,这似乎是您原始问题中的故障点,您需要输入有效的 OpenID。您尝试的 URL 似乎是 OAuth 2.0 客户端示例的 URL,它不是 OpenID。

您应该使用 OpenIdProvider 示例提供的标识符登录到授权服务器,或者(最容易)如果您有 Yahoo 帐户,则使用“yahoo.com”或“tinyurl.com/googop”使用 Google 登录。

于 2012-06-21T15:19:27.093 回答
0

除非我弄错了(这并非完全不可能),否则该AuthorizationServer示例几乎可以充当网关,通过向用户授权 OpenID 提供程序来验证 OAuth 请求。您可以尝试输入 OpenID 提供者 URL,而不是放入依赖方的 URL。(即使是为了测试,您应该可以使用您可能拥有帐户的任何公共提供商

于 2012-06-19T19:17:28.310 回答