I am building a service in go that acts as a public api endpoint. Some of the calls that I make require a user to be authenticated. I am currently working with keycloak as my auth provider, and following the example in this question as to how to communicate between my endpoint and keycloak (though I think this question would apply to any oidc provider). The answer to that question uses "somestate" as the state, and from the reading I have done, it is undesirable to use a static state, or a plain text state. Given that the service may be scaled eventually, I would also prefer to not require storage of some form, either in memory or database.
How do I use the request that I originally received to generate a unique state that I can then decode after the redirect, and validate in a possibly different service?
I assume that I would encrypt something and put that in the state, but I am not sure what to encrypt, and not sure how to encrypt it properly.