I’ve got a c# .net core 3.1 web api, and I need to call the okta API to log in a user at startup time, to prime the pump on authentication, because the first okta authentication takes over 5 seconds and I don’t want my users waiting that long.
Unfortunately I have no idea how to do this, what apis do I call? what methods? Is their documentation? examples?
If so there is no documentation on setting up what you want. The first protected API call will take extra time not only because intitializing etc, but the /keys endpoint for Okta needs to be called.
You could put together a call where you have an access_token (can be an invalid signature that is fine) minted by the Okta Auth server you are using, just make sure the expiry_time is set to some value far in the future. Once the application loads have the application call one of the protected API endpoints with that access_token so the library loads and downloads the /keys from the authorization server.
Yeah I totally get that i need to authenticate and that i can use a bad token, i just needed a code sample on how to do that.
Here is an article that I foud from 2018, that gives a code sample on manually authenticating a token. It was very helpful in priming the pump.
I hope it is helpful to someone else.
Skip to the section “validate tokens manually in aspnet core” for the code sample on manually validating a token. I just call that method with a bad token and that primes the pump making the first real call to okta much faster.