<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Forgejo on Haseeb Majid</title>
    <link>https://haseebmajid.dev/tags/forgejo/</link>
    <description>Haseeb Majid&#39;s blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Thu, 03 Dec 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://haseebmajid.dev/tags/forgejo/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>TIL - How to Log In to Self-Hosted Forgejo with fj</title>
      <link>https://haseebmajid.dev/posts/2026-12-03-til-how-to-log-fj-into-self-hosted-forgejo/</link>
      <pubDate>Thu, 03 Dec 2026 00:00:00 +0000</pubDate>
      <guid>https://haseebmajid.dev/posts/2026-12-03-til-how-to-log-fj-into-self-hosted-forgejo/</guid>
      <description>&lt;p&gt;Recently I was moving my projects from GitLab to my self-hosted Forgejo instance. I wanted to use &lt;code&gt;fj&lt;/code&gt; &lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;https://haseebmajid.dev/posts/2026-12-03-til-how-to-log-fj-into-self-hosted-forgejo/#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; like
I use &lt;code&gt;glab&lt;/code&gt; and &lt;code&gt;gh&lt;/code&gt;, but &lt;code&gt;fj auth login&lt;/code&gt; couldn&amp;rsquo;t find a client ID for my instance.&lt;/p&gt;
&lt;p&gt;I created an OAuth app in Forgejo, and that got the browser to open, but the login still failed.
Go to &lt;strong&gt;Settings → Applications&lt;/strong&gt; in Forgejo and create an OAuth2 app with &lt;strong&gt;Confidential Client&lt;/strong&gt;
unchecked. Set the redirect URI to &lt;code&gt;http://127.0.0.1:26218/&lt;/code&gt; (including the trailing slash).&lt;/p&gt;</description><content:encoded><![CDATA[<p>Recently I was moving my projects from GitLab to my self-hosted Forgejo instance. I wanted to use <code>fj</code> <sup id="fnref:1"><a href="https://haseebmajid.dev/posts/2026-12-03-til-how-to-log-fj-into-self-hosted-forgejo/#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup> like
I use <code>glab</code> and <code>gh</code>, but <code>fj auth login</code> couldn&rsquo;t find a client ID for my instance.</p>
<p>I created an OAuth app in Forgejo, and that got the browser to open, but the login still failed.
Go to <strong>Settings → Applications</strong> in Forgejo and create an OAuth2 app with <strong>Confidential Client</strong>
unchecked. Set the redirect URI to <code>http://127.0.0.1:26218/</code> (including the trailing slash).</p>
<p>Then add your Forgejo hostname and the client ID to <code>~/.config/forgejo-cli/client_ids</code>:</p>
<div class="lab-neovim" data-code-lines="1" data-code-filename="snippet.txt" data-code-lang="text">
  <div class="lab-code-tab">
    <span class="lab-code-filename" title="snippet.txt">snippet.txt</span>
  </div>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">forgejo.example.com YOUR_CLIENT_ID</span></span></code></pre></div>
  <div class="lab-code-bar">
    <b class="lab-code-lang">text</b>
    <span class="lab-code-lines">1 line</span>
    <span class="lab-code-copy"></span>
  </div>
  <div class="lab-code-command" role="status">"snippet.txt" 1L</div>
</div>
<p>Then sign in:</p>
<div class="lab-neovim" data-code-lines="1" data-code-filename="snippet.sh" data-code-lang="bash">
  <div class="lab-code-tab">
    <span class="lab-code-filename" title="snippet.sh">snippet.sh</span>
  </div>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">fj auth login -H forgejo.example.com</span></span></code></pre></div>
  <div class="lab-code-bar">
    <b class="lab-code-lang">bash</b>
    <span class="lab-code-lines">1 line</span>
    <span class="lab-code-copy"></span>
  </div>
  <div class="lab-code-command" role="status">"snippet.sh" 1L</div>
</div>
<blockquote>
<p>Use the hostname you open in your browser. In my setup <code>fj</code> was picking up the SSH host and port from my Git
remote, so I had to pass <code>-H</code> explicitly.</p>
</blockquote>
<p>I put the <code>client_ids</code> file in my Home Manager config. The client ID isn&rsquo;t a secret, so you can put it there
in plain text.</p>
<p>That&rsquo;s it!</p>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p><a href="https://codeberg.org/forgejo-contrib/forgejo-cli">Forgejo CLI repository</a>&#160;<a href="https://haseebmajid.dev/posts/2026-12-03-til-how-to-log-fj-into-self-hosted-forgejo/#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
