0

I'm integrating a .Net Core Api app with a third party Api. The third party Api requires the use of OAuth2. The OAuth2 requires the authorization code approach to exchange for OAuthToken for Api to Api http requests for no user involvement scenarios. I want to use the IdentityModel.AspNetCore nuget package for managing the token lifecycle by registering it in with builder.Services following the Worker approach.

All of the examples and articles I'm finding use the ClientCredentialsTokenRequest whereas I need to use the AuthorizationCodeTokenRequest to obtain the OAuthToken.

I can register it as shown below ...

builder.Services.AddClientAccessTokenHttpClient("deskApi", configureClient: client =>
{
    client.RequestAuthorizationCodeTokenAsync(new AuthorizationCodeTokenRequest
    {
        Address = builder.Configuration["DeskApi:Address"],
        ClientId = builder.Configuration["DeskApi:ClientId"],
        ClientSecret = builder.Configuration["DeskApi:ClientSecret"],
        Code=builder.Configuration["DeskApi:Code"]                 
    });

    client.BaseAddress = new Uri("https://desk.zoho.com/api/v1/tickets/");
});

... but I believe I need to add it to the...

builder.Services.AddClientAccessTokenManagement()

...so the IdentityModel.AspNetCore library manages the OAuthToken lifecycle?

Limited info out there on implementing AuthorizationCodeTokenRequest and I've been stuck on this for a bit now... Any suggestions?

JReam
  • 898
  • 2
  • 13
  • 28

0 Answers0