I am building a SAAS website that will have a CLI tool as well and am currently looking into how I want to handle AuthN/AuthZ. Ideally I can use the same authentication mechanism for my frontend, backend, and CLI. I'm looking into using clerk for this.
I set it up in a test Next.js
app and find it really easy to use on the website portion. What I am not sure about is how to use clerk to authenticate with a CLI.
I'm looking to do something similar to GitHub CLI's gh auth login
to generate a token that can be used to authenticate requests and would love it if I could get the CLI login to navigate to my Web UI to generate the token.
Has anyone set this up before and possibly have some code samples?
I wanted to share that I did some digging through the clerk discord and found an unofficial code example for this using Node.js. Here it is, I plan on using it as a reference for my CLI tool. https://github.com/clerk/cli-auth-unofficial-example