2013-08-19 37 views
2

我想將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) 

據網絡跟蹤,從來都沒有命中谷歌。

謝謝!

回答

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 
相關問題