I came across this error trying to validate tokens between a React app and an Okta developer page and Stack Overflow was giving me nothing.
On the client side, I was using the oidc-client.js, like so:
const oidcConfiguration: any = { authority: env.__AUTH_AUTHORITY__, redirect_uri: env.__AUTH_REDIRECT_URI__, post_logout_redirect_uri: env.__AUTH_POST_LOGOUT_REDIRECT_URI__, silent_redirect_uri: env.__AUTH_SILENT_RENEW_URI__, client_id: env.__AUTH_CLIENT_ID__, response_type: 'id_token token', scope: 'openid profile email', }
The authority was my dev account, something like https://dev-123456.okta.com
. I got this working and managed to get myself an access token.
On the .net core side, I was using basic JWT validation. I had been using Okta’s example but they amount to the same thing.
// Add JWT Bearer authentication services.AddAuthentication( sharedOptions => { sharedOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; sharedOptions.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; } ) .AddJwtBearer( options => { options.Authority = this._configuration["Auth:Authority"]; options.Audience = this._configuration["Auth:Audience"]; } );
Using the same authority as getting the token, I got an error message that told me I needed to set up an authorization server. I set one up that was, by default, something like https://dev-123456.okta.com/oauth2/default
. When I tried to authenticate my token against this server, I got the error “Signature validation failed. Unable to match ‘kid’”.
The solution turned out to be pretty simple: The client has to be changed to also use https://dev-123456.okta.com/oauth2/default
to get the token instead of just https://dev-123456.okta.com
.