This repository contains a sample of protecting API endpoints using Okta in a .NET Core Web API.
The sample uses the Okta.AspNetCore Nuget package. Read more about getting started with Okta and authentication best practices on the Okta Developer Portal.
This code sample demonstrates
- Configuring Okta
- Protecting routes
- Reading claims values
You will need the .NET Core 3.1 SDK.
To run this example, run the following commands:
git clone https://github.com/okta-samples/okta-dotnetcore3-api-quickstart.git
cd okta-dotnetcore3-api-quickstart
Restore the Nuget packages.
Create a free developer account with the following command using the Okta CLI:
okta register
You will need your Okta domain and Audience.
Update appsettings.json
with your Okta settings adding Okta
as a top level property.
"Okta": {
"OktaDomain": "https://{yourOktaDomain}",
"AuthorizationServerId": "default",
"Audience": "api://default"
}
Start the app by running in the IDE.
Use your favorite HTTP Client to call the API. For authenticated calls, follow the steps in Send a request to your API endpoint using Postman of the quick start.
Please visit our Okta Developer Forums.