2

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

            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)

根据网络跟踪,谷歌从未受到任何影响。

谢谢!

4

1 回答 1

1

我也有这个问题。我的解决方案是仔细检查服务根目录中的 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
于 2014-04-28T08:45:51.173 回答