Skip to main content
DeveloperHandbook.com

How to use AWS Cognito with .NET Core

Published on December 09, 2018 in Cognito · Read time 5 minutes

I never would have believed just a couple of years ago that I would be typing these words. With just a few lines of code you can add authentication and authorisation to your cross platform .NET web application in a secure way using Amazon Web Services (AWS) Cognito API. You can either call the API directly with POST requests, or take advantage of the built in user interface. As an added bonus, Cognito supports federated identities, allowing you to use external identity providers such as Google and Facebook to enable users to log in to your application quickly without having to enter a username or password. This post will focus specifically on authentication, and a follow-up post will cover authorization. We assume that you already have an AWS account. We have used Jetbrains Rider on a Macbook Pro, although you could use Visual Studio on Windows instead. A list of specific versions of each library used can be found at the end of this post. Project Setup Start by creating a new .NET Core Web API application as shown. You could alternatively run the following command from the command line to achieve the same; With the project scaffolded, run it and open the browser to https…