问题
I'm trying to get the user data through IAuthSession after a doing an authentication with facebook, when I try get the user with Request.GetSession(true) which returns AuthUserSession (implements IAuthSession) I get a partial subset of data like the following:
I'm trying to use it in a service method
[ClientCanSwapTemplates]
[DefaultView("dashboard")]
public DashboardResponse Get(FacebookRequest userRequest)
{
var user1 = Request.GetSession(true);
return new DashboardResponse();
}
I've added the auth providers my apphost as follows:
Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
new FacebookAuthProvider(appSettings),
new TwitterAuthProvider(appSettings),
new BasicAuthProvider(appSettings),
new GoogleOpenIdOAuthProvider(appSettings),
new LinkedInAuthProvider(appSettings),
new CredentialsAuthProvider()
}));
As far as I know the facebookAuthProvider should fill the IAuthSession with the following information:
userSession.FacebookUserId = tokens.UserId ?? userSession.FacebookUserId;
userSession.FacebookUserName = tokens.UserName ?? userSession.FacebookUserName;
userSession.DisplayName = tokens.DisplayName ?? userSession.DisplayName;
userSession.FirstName = tokens.FirstName ?? userSession.FirstName;
userSession.LastName = tokens.LastName ?? userSession.LastName;
userSession.PrimaryEmail = tokens.Email ?? userSession.PrimaryEmail ?? userSession.Email;
what step am I missing?
回答1:
I was in a similar situation like this issue based the answer I decided to try that out, and It worked.
the only difference is that I'm using simple injector and you have to consider to register that dependency as Singleton the easier way for me to register it was this:
simpleInjectorContainer.RegisterSingle<ICacheClient>(()=>new MemoryCacheClient());
来源:https://stackoverflow.com/questions/18200419/servicestack-iauthsession-empty-after-authentication-with-facebookauthprovider