servicestack,dotnetopenauth,Oauth,Openid,servicestack,Dotnetopenauth" /> servicestack,dotnetopenauth,Oauth,Openid,servicestack,Dotnetopenauth" />

Oauth (Google)OpenId身份验证具有InvalidOperationException

Oauth (Google)OpenId身份验证具有InvalidOperationException,oauth,openid,servicestack,dotnetopenauth,Oauth,Openid,servicestack,Dotnetopenauth,我正在尝试使用ServiceStack.authentication.OpenId包启动和运行谷歌的身份验证。我遵循了SocialBootStrap示例,但不知道我错过了什么 我已将身份验证提供程序添加到我的apphost: Plugins.Add(new AuthFeature(() => new CustomUserSession(), new IAuthProvider[] { new CredentialsAuthProvider(), /

我正在尝试使用ServiceStack.authentication.OpenId包启动和运行谷歌的身份验证。我遵循了SocialBootStrap示例,但不知道我错过了什么

我已将身份验证提供程序添加到我的apphost:

Plugins.Add(new AuthFeature(() => new CustomUserSession(), new IAuthProvider[] { 
                    new CredentialsAuthProvider(), //HTML Form post of UserName/Password credentials
                    new TwitterAuthProvider(appSettings),       //Sign-in with Twitter
                    new FacebookAuthProvider(appSettings),      //Sign-in with Facebook
                    new GoogleOpenIdOAuthProvider(appSettings), //Sign-in with Goolge OpenId
                    new WsFedSamlAuthProvider(appSettings)
                    })
我已将配置设置添加到我的app.config(我正在运行一个自主机应用):

我已经尽可能地遵循了这些例子,我想我遗漏了什么


感谢您的期待。

正如错误所述,问题与没有HTTP上下文有关。这是因为我运行的是自托管应用程序ie,而不是IIS

要在此环境中工作,必须为dotnetopenauth提供自定义应用程序存储。存储区是存储加密密钥和nonce的地方,在IIS环境中,dotnetopenauth将使用通过HTTP上下文访问的应用程序缓存

为了解决这个问题,我编写了一个由本地REDIS客户端和自定义OpenIdAuthentication提供程序支持的自定义应用程序存储

我在这里列出了我的代码要点。这适用于我基于OpenId编写的STS服务器,但似乎不适用于Servicestack中的OpenId提供程序-需要更多的调查

<add key="oauth.googleopenid.AppId" value="XXX" />
<add key="oauth.googleopenid.AppSecret" value="XXX" />
<add key="oauth.googleopenid.RedirectUrl" value="http://XXX" />
<add key="oauth.googleopenid.CallbackUrl" value="http://XXX/api/auth/googleopenid" />
<form action="/api/auth/googleopenid" method="POST">
    <button class='btn' type='submit'>Sign-in with Google</button>
</form>
errorCode: InvalidOperation
Exceptionmessage:  No current HttpContext was detected, so an IOpenIdApplicationStore instance must be explicitly provided or specified in the .config file. Call the constructor overload that takes an IOpenIdApplicationStore.stack 
Trace[Auth: 08/01/13 20:49:30]: [REQUEST: {provider:googleopenid}]System.InvalidOperationException: No current HttpContext was detected, so an IOpenIdApplicationStore instance must be explicitly provided or specified in the .config file. Call the constructor overload that takes an IOpenIdApplicationStore. at DotNetOpenAuth.Messaging.ErrorUtilities.VerifyOperation(Boolean condition, String errorMessage, Object[] args) at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty.get_HttpApplicationStore() at DotNetOpenAuth.OpenId.RelyingParty.OpenIdRelyingParty..ctor() at ServiceStack.Authentication.OpenId.OpenIdOAuthProvider.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 lambda_method(Closure , Object , Object ) at ServiceStack.ServiceHost.ServiceRunner`1.Execute(IRequestContext requestContext, Object instance, TRequest request)