ServiceStack IAuthSession empty after authentication with FacebookAuthProvider

末鹿安然 提交于 2020-01-11 12:25:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!