Carlos G.
Carlos G.

Reputation: 4634

Issue an access token for an IdentityServer4 instance

Inside an application that is running IdentityServer4, I want to get an access token so that that the app can access another service that requires authentication. I found this answer that addresses IdentityServer3. I want to know if there is a similar mechanism in IdentityServer4.

I've already tried searching the github repo for IssueClientToken but got no hits.

Upvotes: 1

Views: 1589

Answers (1)

LugTread
LugTread

Reputation: 343

As was pointed out to me in this post, you can inject IdentityServerTools into your class and use the exposed methods to create access tokens for Identity Server extensibility points. For instance a short lived token for a resource api might look like this:

     // generate short lived token
     var accessToken = await _identityServerTools.IssueJwtAsync(500, 
         new Claim[] { new Claim(JwtClaimTypes.Audience, "resourceApi") });

Upvotes: 5

Related Questions