Multiple identities | Auth0 + external system via API | ASP.NET Core MVC 2.2

I have been using Auth0 authentication successfully with my web app for quite a while.

I now have a need to communicate to a cloud-based system via their API which itself requires authentication. I have used their test app (in isolation) and I can authenticate successfully.

The problem I have is to incorporate both authentications into the one program.

My scenario is briefly as follows:

  1. A user logs in to my web app and authenticates via Auth0. [works ok]
  2. The authenticated user uses my web app. [works ok]
  3. At some later time, the user wants to read some data from an external system. In order to call their API, the user needs to authenticate against the the external system. [not working]
  4. Once authenticated, my app would retrieve the necessary data from the external system and show the information in my web app.

In step 3 above, I don’t understand how to write the code in the ConfigureServices method in startup.cs so that I end up with 2 separate identity objects. One for my web app and the other for the external system.

I’m hoping someone can help me or show me some example code.

I should add that the third-party app that I need to communicate with (via their api), also uses the Oauth 2 protocol - which should make life easier.