Reputation: 53
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?
Upvotes: 3
Views: 73
Reputation: 4412
I had exactly the same use case and I reached out to Clerk's support.
They responded that this is definitely possible and they pointed me to this blog from Turso: https://turso.tech/blog/why-we-transitioned-to-clerk-for-authentication that gives some hints on how they used Clerk with their CLI.
I haven't tried it myself yet but I thought to share it!
Upvotes: 0
Reputation: 53
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
Upvotes: 1