servicestack oauth2 google身份验证不适用于自托管站点

时间:2013-11-21 22:36:06

标签: oauth servicestack self-hosting

我一直在尝试将Google的OAuth2提供程序添加到构建在ServiceStack上的概念验证应用程序中,但是当我尝试启动登录时,我不断收到以下错误...

This method requires a current HttpContext. Alternatively, use an overload of this method that allows you to pass in information without an HttpContext`enter code here`

[Auth: 11/21/2013 10:29:25 PM]: [REQUEST: {provider:googleoauth}] System.InvalidOperationException: This method requires a current HttpContext. Alternatively, use an overload of this method that allows you to pass in information without an HttpContext. at DotNetOpenAuth.Requires.ValidState(Boolean condition, String message) at DotNetOpenAuth.Messaging.Channel.GetRequestFromContext() at DotNetOpenAuth.OAuth2.WebServerClient.ProcessUserAuthorization(HttpRequestBase request) at ServiceStack.Authentication.OAuth2.OAuth2Provider.Authenticate(IServiceBase authService, IAuthSession session, Auth request) at ServiceStack.ServiceInterface.Auth.AuthService.Authenticate(Auth request, String provider, IAuthSession session, IAuthProvider oAuthConfig) at ServiceStack.ServiceInterface.Auth.AuthService.Post(Auth request) at ServiceStack.ServiceInterface.Auth.AuthService.Get(Auth request) at lambda_method(Closure , Object , Object ) at ServiceStack.ServiceHost.ServiceRunner`1.Execute(IRequestContext requestContext, Object instance, TRequest request)

我还下载了演示应用程序SocialBootstrapApi并将Google Oauth2提供程序添加到其中,并且能够让它运行起来。我已经将配置从web.config复制到自托管项目的app.config文件中,但它仍然不起作用。

任何帮助都会很棒!

感谢您的帮助。

1 个答案:

答案 0 :(得分:-1)

ServiceStack.AuthWeb.Tests是一个ASP.NET WebHost,显示all the ServiceStack AuthProviders在单个应用中运行。

请注意 OAuth2 提供商使用Web.config中指定的其他配置,这需要您注册自己的应用以获取应用的消费者密钥和密钥。出于测试目的,您可以使用已嵌入Web.config中的ServiceStack测试密钥。

OAuth2 section in the Authentication wiki提供了您可以为每个提供商注册申请的网址。