Identityserver4: Custom user service GetProfileDataAsync not getting called

Created on 21 Oct 2016  路  6Comments  路  Source: IdentityServer/IdentityServer4

Implemented a custom service class derived from IProfileService. The custom impl of GetProfileDataAsync is not getting called. Can somebody tell me what is being done wrong or what needs to be done?

I have the following in startup

.AddProfileService<IdentityWithAdditionalClaimsProfileService>() .SetSigningCredential(cert) .AddOperationalStore(builders => builders.UseSqlServer(connectionString, options => options.MigrationsAssembly(migrationsAssembly))) .AddConfigurationStore(builders => builders.UseSqlServer(connectionString, options => options.MigrationsAssembly(migrationsAssembly))) .AddAspNetIdentity<ApplicationUser>();

Thanks

question

Most helpful comment

In my case switching the places of .AddProfileService<TService>() and .AddAspNetIdentity<TUser>() solved the problem.
So instead of:
.AddProfileService<IdentityProfileService>();
.AddAspNetIdentity<ApplicationUser>();
Declare
.AddAspNetIdentity<ApplicationUser>();
.AddProfileService<IdentityProfileService>();

All 6 comments

On further investigation looks like the constructor of the custom service is not getting called. I am also adding a TransientService for the custom user service.

services.AddTransient<IProfileService, IdentityWithAdditionalClaimsProfileService>();

inspect the IServiceCollection at the the end of ConfigureServices to make sure your implementation is in the container.

@leastprivilege why my profile service not added in container by services.AddProfileService call?

In my case switching the places of .AddProfileService<TService>() and .AddAspNetIdentity<TUser>() solved the problem.
So instead of:
.AddProfileService<IdentityProfileService>();
.AddAspNetIdentity<ApplicationUser>();
Declare
.AddAspNetIdentity<ApplicationUser>();
.AddProfileService<IdentityProfileService>();

In my case switching the places of .AddProfileService<TService>() and .AddAspNetIdentity<TUser>() solved the problem.

I don't know how you stumbled into figuring that out but bless you for it, you just stopped my bleeding at two hours of wasted time.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

krgm03 picture krgm03  路  3Comments

ekarlso picture ekarlso  路  3Comments

Aravind1729 picture Aravind1729  路  3Comments

osmankibar picture osmankibar  路  3Comments

agilenut picture agilenut  路  3Comments