Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use openid connect authentication and jwtbearer authentication scheme in one app?

I have an ASP.NET Core web app where the front-end is built in react and for the back-end, I have web APIs, both the things are placed in one web project. for authentication, I used Azure AD open Id connect authentication scheme.

Now I have a requirement where I need to expose some APIs to an external system using client credentials flow. so I am not sure how to implement this in the current web app as it already has the open id connect authentication scheme.

Any idea? Many thanks

like image 634
amol Avatar asked Oct 18 '25 12:10

amol


1 Answers

You need to create two applications in Azure portal. At present, you already have an ASP.NET Core Web application, which represents the front-end application, so you need to create another application that represents the Web API, that is, the back-end application.

First, you need to expose the api of the back-end application protected by Azure, which can be configured according to the following process:

Azure portal>App registrations>Expose an API>Add a scope>Add a client application

enter image description here

Then you need to create the appRole of the back-end application, and then grant that role as an application permission to the client application.

enter image description here

Next, go to client application>API permissions>Add a permission>My APIs>your api application.

enter image description here

Finally, you need to obtain an access token using the client credential flow where no user is logged in:

enter image description here

Parse the token:

enter image description here

Finally, you can pass the token to the api application, and the api application will authenticate the client application by parsing the token.

Similar samples.

like image 135
Carl Zhao Avatar answered Oct 20 '25 09:10

Carl Zhao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!