如何配置ServiceStack.net以使用OAuthProvider对Google进行身份验证



我想将ServiceStack.net配置为使用OAuthProvider对Google进行身份验证。这是我目前的配置:

            Plugins.Add(new AuthFeature(() => new AuthUserSession(),
            new IAuthProvider[] {
                new OAuthProvider(appSettings, 
                    "https://accounts.google.com/o/oauth2/auth", 
                    "google", 
                    "Google Client ID", 
                    "Google Client secret")
            }));

然而,我得到以下错误:

    response Status
    error       Code ArgumentNullException
    message     String reference not set to an instance of a String. Parameter name: s
    stack Trace
[Auth: 8/19/2013 7:48:47 PM]: [REQUEST: {provider:google}] System.ArgumentNullException: String reference not set to an instance of a String. Parameter name: s at System.Text.Encoding.GetBytes(String s) at ServiceStack.ServiceInterface.Auth.OAuthUtils.PercentEncode(String s) at ServiceStack.ServiceInterface.Auth.OAuthAuthorizer.<>c__DisplayClass3.<MakeSignature>b__1(String k) at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at ServiceStack.ServiceInterface.Auth.OAuthAuthorizer.MakeSignature(String method, String base_uri, Dictionary`2 headers) at ServiceStack.ServiceInterface.Auth.OAuthAuthorizer.AcquireRequestToken() at ServiceStack.ServiceInterface.Auth.OAuthProvider.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)

根据网络追踪,谷歌从未受到任何攻击。

谢谢!

我也遇到了这个问题。我的解决方案是仔细检查服务根目录中的Web.Config。我在那里没有正确设置ServiceStack OAuth Config。

使用密钥:

<add key="oauth.GoogleOpenId.RedirectUrl" value="http://bootstrapapi.apphb.com/friends"/>
<add key="oauth.GoogleOpenId.CallbackUrl" value="http://bootstrapapi.apphb.com/api/auth/GoogleOpenId"/>

和谷歌IAuthProvider

new GoogleOpenIdOAuthProvider(appSettings), //Sign-in with Google OpenId

相关内容

  • 没有找到相关文章

最新更新