How to develop a .NET Core 3.1 API secured with Identity Server 4 — Part 2

How to develop a .NET Core 3.1 API secured with Identity Server 4 — Part 2

In the first part of this series, we’ve went over building an Identity Server which will facilitate the security of the API we are building together during this article.

Most modern web applications are backed by a web API (Application Programming Interface) which interacts with one or multiple databases. Of course, you don’t want anyone to call your API, that’s why you need to built a way to restrict or allow access to your endpoints. In the first part of this series, we’ve went over building an Identity Server which will facilitate the security of the API we are building together during this article.

Image for post

Photo by Fotis Fotopoulos on Unsplash

As a first step, let’s open up the “dotnet-api-with-identity-server” solution and create a new .NET Core API project name “my-fancy-api”. If you are new to this series, you’ll find the solution referenced above at the following link: https://github.com/ionepaul/dotnet-api-with-identity-server

We have our new API now, but we need some NuGet packages to help us around with the IdentityServer token validation and with the swagger interface. Open NuGet package manager and install IdentityServer4.AccessTokenValidation (3.0.1) — facilitates the authentication handling and references tokens from IdentityServer4, Swashbuckle.AspNetCore (5.6.3), Swashbuckle.AspNetCore.Swagger (5.6.3) — the first one si mainly for documenting the .NET Core APIs, whereas the second one is a middleware to expose Swagger JSON endpoints from APIs, Microsoft.Extensions.Platform.Abstractions (1.1.0) — used for getting the application based path for reading the xml documentation file. NOTE_:_ The versions written above are the latest versions at the time of writing this article.

Let’s jump on writing some code now. We will start by registering the authentication and authorization in the API pipeline.

software-engineering software-development api web-development programming

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Offshore Software Development - Best Practices

To make the most out of the benefits of offshore software development, you should understand the crucial factors that affect offshore development.

Software Developer vs Software Engineer — Differences: Bogus or Real?

In this article, see if there are any differences between software developers and software engineers. What you’re about to read mostly revolves around my personal thoughts, deductions, and offbeat imagination. If you have different sentiments, add them in the comment section, and let’s dispute! So, today’s topic…

Software Developer vs Web Developer | Difference Web Developer & Software Developer

Software Developer vs Web Developer | Difference Web Developer & Software Developer | Software development and web development are normally used interchangeably. Although both include development, a software developer has different responsibilities from that of a web developer.

Developer or Engineer? Does It Make a Difference?

To summarise the main differences between the software developer and engineer: A developer executes. ... So the software developer is mainly focused on developing code that is a part of software development cycle. An engineer designs and plans applying the principles of engineering to software development.

5 Core Criteria for Selecting Software Development Company - TopDevelopers.co

Check out these five criteria for the selection of your software vendor, and you will never regret having the wrong quality product made for you.