Where does this code go?

Im trying to validate bearer tokens and was looking at this page JWT Validation Guide | Okta Developer
but I am confused as to where I should put this in my .NET project. I feel like it should go either inside the controller, startup.cs, or its own file. It would be nice if there as a change on other pages as well that stated where some of the provided code should go as well for better clarity.