2013-08-19 2 views
2

Je souhaite configurer ServiceStack.net pour qu'il s'authentifie en utilisant OAuthProvider contre Google. Voici ma configuration actuelle:Comment configurer ServiceStack.net pour s'authentifier à l'aide de OAuthProvider par rapport à 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") 
      })); 

Cependant, je reçois l'erreur suivante:

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) 

Selon la trace réseau, rien ne frappe jamais Google.

Merci!

Répondre

1

J'ai également eu ce problème. Ma solution était de vérifier le Web.Config à la racine du service. Je ne disposais pas de la configuration de ServiceStack OAuth Config correctement.

Utilisez les touches:

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

et Google IAuthProvider

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