Skip to content

Latest commit

 

History

History

adding-an-oauth-2-security-scheme-to-an-aspnet-core-5-api

Adding an OAuth 2.0 Security Scheme to an ASP.NET Core 5 API

YouTube

Getting Started

  1. Generate a self-signed certificate.
    openssl req -x509 -newkey rsa:4096 -keyout localhost.key -out localhost.crt -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,DNS:api,DNS:identityserver"
    openssl pkcs12 -export -in localhost.crt -inkey localhost.key -out localhost.pfx -name "Adding an OAuth 2.0 Security Scheme to an ASP.NET Core 5 API"
  2. Import the self-signed certificate.
    certutil -f -user -importpfx Root localhost.pfx
  3. Add the lines below to the hosts file.
    127.0.0.1 api
    127.0.0.1 identityserver
    
  4. Start the applications.
    docker compose up --build
  5. Open the Swagger UI.
  6. Click the Authorize button.
  7. Enter the client_id "console".
  8. Enter the client_secret "secret".
  9. Select the "api" scope.
  10. Click the Authorize button.
  11. Click the Close button.
  12. Send requests to the API.