servicestack,Google Api,Oauth 2.0,servicestack" /> servicestack,Google Api,Oauth 2.0,servicestack" />

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

Google api 如何配置ServiceStack.net以使用OAuthProvider对Google进行身份验证,google-api,oauth-2.0,servicestack,Google Api,Oauth 2.0,servicestack,我想将ServiceStack.net配置为使用OAuthProvider对Google进行身份验证。以下是我当前的配置: Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] { new OAuthProvider(appSettings, "https://accou

我想将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)
响应状态
错误代码异常
消息字符串引用未设置为字符串的实例。参数名称:s
堆栈跟踪
[Auth:8/19/2013 7:48:47 PM]:[REQUEST:{provider:google}]System.ArgumentNullException:字符串引用未设置为字符串的实例。参数名称:s位于System.Text.Encoding.GetBytes(字符串s)位于ServiceStack.ServiceInterface.Auth.OAuthUtils.PercentEncode(字符串s)位于ServiceStack.ServiceInterface.Auth.OAuthAuthorizer.c_uDisplayClass3.b_uu1(字符串k)位于System.Linq.Enumerable.WhereselectEnumerableInterator'2.MoveNext()位于System.Linq.Buffer'1..(IEnumerable'1 source)ServiceStack.ServiceInterface.Auth.OAuthProvider.Authenticate()处的System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)处的ServiceStack.ServiceInterface.Auth.OAuthAuthorizer.MakeSignature(String方法、字符串基uri、字典`2头)处在lambda_方法(闭包、对象、对象)下的ServiceStack.ServiceInterface.Auth.authService.Authenticate(Auth请求、字符串提供程序、IAuthSession会话、IAuthProvider oAuthConfig)上的(IServiceBase authService、IAuthSession会话、Auth请求)在ServiceStack.ServiceHost.ServiceRunner`1.Execute(IRequestContext请求上下文、对象实例、TRequest请求)
根据网络追踪,没有任何东西能击中谷歌


谢谢!

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

使用以下键:

<add key="oauth.GoogleOpenId.RedirectUrl" value="http://bootstrapapi.apphb.com/friends"/>
<add key="oauth.GoogleOpenId.CallbackUrl" value="http://bootstrapapi.apphb.com/api/auth/GoogleOpenId"/>
new GoogleOpenIdOAuthProvider(appSettings), //Sign-in with Google OpenId