I’m attempting to do a Golang CLI proof-of-concept using Okta authentication. I am specifically looking for a sample golang CLI client app that accesses internal APIs using Okta access token (OIDC). I was going through some sample example here but I observed that it uses templates pkg that renders a page on browser at localhost:8080. I need replicate the same but from CLI terminal and need to launch Okta authentication directly from there. Any sample app example for this requirement will greatly help. Thanks.
I understand that you might want a CLI in Go that can launch a browser, go through the authentication flow with Okta, then get tokens back to the CLI. These tokens can then be used for its own API calls against an external resource with Okta tokens.
If this is the case, while we don’t have an exact example, here’s a suggested approach:
Start an HTTP server within the CLI and set it as the callback URI for the authorization code flow. Generate the authorize call and launch a browser with it. After auth, you can redirect back to the HTTP server in your app. This server would then retrieve the tokens from Okta and shut down the HTTP server.
If you prefer not to launch a browser and want everything done from the CLI, the process becomes more complex, depending on the factors you want to support. Could you please provide more details on this?
@piyusha Thanks for replying on this thread. The idea of this CLI /TUI app is to have a login screen that will authenticate user via Okta and then use this token for calling APIs from different services internally backed by Okta authentication.
I can understand not launching a browser can become more complex but that would be an ideal scenario. Would love to know if that is possible.
P.S. planning to use some external TUI frameworks like charm/bubble-tea.