To learn Auth0, I cloned their sample glossary project and upgraded it to net8
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<UseAppHost>false</UseAppHost>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.11" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
</ItemGroup>
</Project>
I also added a .sln
When I run, I see the swagger ui
I set up the api in Auth0 with an application to use it. The application has the permissions checked.
In appsettings I have put
"Auth0": {
"Domain": "myoauthtenant.au.auth0.com",
"Audience": "https://glossary.com",
"ClientId": "GS9.. etc",
"ClientSecret": "BYl2.. etc"
}
I have tried creating a token using both the Test tab in the OAuth0 api and the Test tab in the OAuth0 application
I also raised my issue on GitHub.
I have my API Authorised in my Test Application
I copy the bearer token from the Test Application Quickstart tab and paste it into Swagger Authorize Input Then Try out Post
The authorization documentation is here.
[Update] I started with branch main instead of following the tutorial exactly. This may have to do with my problem.
[Update]
I missed this step in the API Settings
As far as I know, that project should work in .NET 8 as well.
I'm afraid you are mixing instructions for configuring an API and an OAuth client application. For example, you don't need ClientId
and ClientSecret
in appsettings.json
to configure the API.
Follow the instructions in this article to test the API (by the way, this is the article attached to that sample project)