I've successfully set up an application on the Okta portal, configured it to use the "Client Credentials" OAuth 2.0 grant type, and obtained a public-private key pair. I'm currently trying to generate and validate a token in C# using the private key from Okta.
Here's what I've tried so far in C# to validate the token:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidIssuer = "myIssuer",
ValidateAudience = true,
ValidAudience = "myAudience",
ValidateLifetime = true
};
});
When I run this code, I get a 'token invalid' message without any additional details. Could someone guide me through the process of generating and validating a token with Okta or point me to resources that could help me solve this issue? I need to use Client credentials because I don't have users in Okta, I need this token when calling an API just to secure my api. Thank you!