Recently I was moving my projects from GitLab to my self-hosted Forgejo instance. I wanted to use fj 1 like I use glab and gh, but fj auth login couldn’t find a client ID for my instance.

I created an OAuth app in Forgejo, and that got the browser to open, but the login still failed. Go to Settings → Applications in Forgejo and create an OAuth2 app with Confidential Client unchecked. Set the redirect URI to http://127.0.0.1:26218/ (including the trailing slash).

Then add your Forgejo hostname and the client ID to ~/.config/forgejo-cli/client_ids:

snippet.txt
forgejo.example.com YOUR_CLIENT_ID
text 1 line
"snippet.txt" 1L

Then sign in:

snippet.sh
fj auth login -H forgejo.example.com
bash 1 line
"snippet.sh" 1L

Use the hostname you open in your browser. In my setup fj was picking up the SSH host and port from my Git remote, so I had to pass -H explicitly.

I put the client_ids file in my Home Manager config. The client ID isn’t a secret, so you can put it there in plain text.

That’s it!