- 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"
- Import the self-signed certificate.
certutil -f -user -importpfx Root localhost.pfx
- Add the lines below to the hosts file.
127.0.0.1 api 127.0.0.1 identityserver
- Start the applications.
docker compose up --build
- Open the Swagger UI.
- Click the Authorize button.
- Enter the client_id "console".
- Enter the client_secret "secret".
- Select the "api" scope.
- Click the Authorize button.
- Click the Close button.
- Send requests to the API.
adding-an-oauth-2-security-scheme-to-an-aspnet-core-5-api
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||