Aylmer carson - 343 - Dec 10, 2013

Recently upgraded a large project to ss 4. largely a success, but i’n having problems in a couple of areas.

for example, in a CustomCredentialsAuthProvider, I have:

 public override bool TryAuthenticate(IServiceBase authService, string userName, string password){


            if (authRepo.TryAuthenticate(userName, password, out userAuth))
            {
                session.PopulateWith(userAuth);
                session.IsAuthenticated = true;
                session.UserAuthId = userAuth.Id.ToString(CultureInfo.InvariantCulture);
                session.ProviderOAuthAccess = authRepo.GetUserOAuthProviders(session.UserAuthId)
                    .ConvertAll(x => (IAuthTokens)x);
                cache.Remove(cacheKey);
                return true;
            }

}

the line:

                session.ProviderOAuthAccess = authRepo.GetUserOAuthProviders(session.UserAuthId)
                    .ConvertAll(x => (IAuthTokens)x);

fails with error: no definition for GetUserOAuthProviders

can anyone help with this?

thanks

IAuthUserDetails implement IAuthTokens so it should just be a matter of updating the name, e.g:

session.ProviderOAuthAccess = authRepo.GetUserAuthDetails(session.UserAuthId).ConvertAll(x => (IAuthTokens)x);

Wayne Brantley:

Looks like it is now “LoadUserOAuthProvider” ?

Yeah a lot of ‘OAuth’ was renamed to ‘Auth’ when it made sense to do so.

aylmer carson:

nope, can’t see that

aylmer carson:

authRepo is defined as:

var authRepo = authService.TryResolve<IUserAuthRepository>();

ok here’s the new definition of IAuthRepository: https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack/Auth/IAuthRepository.cs 

So you’re probably after IAuthRepository.GetUserAuthDetails as UserOAuthProvider models was renamed to UserAuthDetails 

aylmer carson:

yes I saw that but how does it help me get the provider? or am I missing it again?

It’s the provider model, i.e. info about the auth provider that’s filled in with what info is available, here’s the complete model: https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack/Auth/UserAuth.cs#L117

aylmer carson:

yes saw that too…but what is wrong with that line? how do I populate the authtokens?

aylmer carson:

thanks. but that is the problem. GetUserAuthDetails doesn’t exist!

Are you sure you’re not referencing an old dll? it’s here: https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack/Auth/IAuthRepository.cs#L9

aylmer carson:

is GetUserAuthDetails  replacing GetUserOAuthProviders?

Yeah I provided the source code in the last comment: 
session.ProviderOAuthAccess = authRepo.GetUserAuthDetails(session.UserAuthId).ConvertAll(x => (IAuthTokens)x);

aylmer carson:

yes I saw that. sorry for all the hassle. :slight_smile:

aylmer carson:

and thanks for all the help!

ok cool, glad its working now.