Open Closed

Accessing the ServiceProvider in the IOpenIddictServerHandler class #5964


User avatar
0
ademaygun created
  • ABP Framework version: v7.3.2
  • UI Type: Angular
  • Database System: EF Core (PostgreSQL
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace: No exception
  • Steps to reproduce the issue:

As expressed by the user @mgurer , the methods of the class we implemented from IAbpClaimsPrincipalContributor are not being triggered in the refresh token flow. Therefore, we created a class derived from MyPrepareAccessTokenPrincipal. However, within the HandleAsync, how can we use our repository class?

public ValueTask HandleAsync(OpenIddictServerEvents.ProcessSignInContext context)
    {
	    var identity = context.AccessTokenPrincipal?.Identities.FirstOrDefault();
		var userId = identity?.FindUserId();
		if (userId!=null)
		{
		  var user = userRepository.GetAsync(userId); //<-- HOW CAN I INJECT userRepository
		}
		
        return default;
    }

1 Answer(s)
  • User Avatar
    1
    liangshiwei created
    Support Team Fullstack Developer

    Hi, you can use dependency injection:

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 19, 2025, 10:09