Pavel Voronin
Pavel Voronin

Reputation: 13985

Is it possible to cal IdentityServer4 API to issue a token?

When I host Identity Server in my Service it exposes '/connect/token' endpoint which I can call with IdentityModel library.

Is it possible to access IS4 services directly?

Something like this:

someIS4Service.IssueTokenAsync(subj, claims, ...other params...) where someIS4Service is simply injected with ASP.NET Core DI.

So created tokens are automatically persisted in DB, as they would if endpoint were accessed?

Upvotes: 0

Views: 85

Answers (1)

d_f
d_f

Reputation: 4859

Technically that's possible, but with a bit more work than a simple call: you may look for ITokenResponseGenerator in the DI and invoke the ProcessAsync method, but you have to provide a pre-processed TokenRequestValidationResult.

As a service you most likely do not need that. You might need to create an access token to perform a service-to-service call and that's easy to do with IdentityServerTools (no persistence, no session handling, just an easy approach to jwt generation).

Upvotes: 1

Related Questions