• (English edition of leo’s Chinese original 設定-n8n-的-GitHub-憑證.)
  • Gemini_Generated_Image_d6oj8cd6oj8cd6oj.jpeg
  • ⚠️ If several people are signing up for GitHub from the same network at the same time, turn off Wi-Fi and switch to mobile data first. GitHub treats a burst of signups from one network as an attack and blocks them.

  • Why GitHub is good for AI — and for you

    • Think of it as the engineer’s Facebook — you post your work and people look at it, star it.
    • We’re not using it to socialize, though. Three reasons:
      • Every change is logged. Who changed which line, when — all of it is kept. If AI writes something wrong or deletes something by mistake, you can see exactly what it touched and roll it back.
      • It’s built for plain text. Markdown files render directly on GitHub, no extra software needed. It’s the format AI works with most efficiently — fewer tokens, lower cost.
      • It’s the best working environment for AI. A full API means any AI agent can read and write to it. Files live in the cloud, versioned, readable by both machines and humans.
    • n8n needs a key to GitHub’s door

      • n8n is a robot — it can’t type in a username and password.
      • Getting this key takes a few more steps than a typical API key, because GitHub lets you decide exactly which doors this key can open.
      • You’ll bounce between two websites during the process.

  • n8n.webp​ @n8n | Step 1 — Choose the credential type

    • 截圖 2026-09-01 下午2.31.59.png
      • GitHub is simple — create it straight from the Credential screen. Click the orange Add credential button in the top right.
    • 截圖 2026-09-01 下午2.34.19.pngAdd credential → type github into the search box, two options show up.
    • Pick GitHub API. (The other one, OAuth2, requires registering an application — a lot more hassle.)
    • 截圖 2026-09-01 下午2.35.28.png
      • Search “github”, two options appear — choose GitHub API
    • Three empty fields appear. Don’t fill them in yet, and don’t close this tab — you don’t have the key yet.
    • 截圖 2026-09-01 下午2.38.09.png
      • On the GitHub credential setup screen, we only need the User and Access Token — leave everything else alone

  • github-logo.png​ @GitHub | Step 2 — Get the key

    • ⚠️ Open a new tab for this. Keep the n8n tab open.
    • 2-1 Sign up for a GitHub account

      • https://github.com/signup — signing up with a Google account is fastest and has the fewest hiccups.
      • Signing up with Apple or plain email is, in practice, more of a hassle.
    • 2-2 Find your username

      • Most sites register you by email, but GitHub identifies you by username. You’ll need to type it in more than once, so know where to find it. Two ways:
        • Click your avatar in the top right — the first line of the menu is your username, click to copy.
        • Or read it off the address bar: github.com/your-username.
      • 截圖 2026-09-01 下午2.40.42.png
        • Click your avatar in the top right to copy your username
    • 2-3 Create a token (what n8n calls “Access Token”, other sites call “API Key”)

      • This token isn’t the “AI token” you may have heard of — it’s GitHub’s equivalent of an API key: credentials that let a machine log in on your behalf.
        1. Site-wide settings: avatar in the top right → Settings
        • 截圖 2026-09-01 下午2.44.06.png
          • Site-wide settings live right under your avatar in the top right
        1. Developer settings: scroll to the very bottom of the left sidebar → Developer settings
        • 截圖 2026-09-01 下午2.46.59.png
          • After opening Settings, scroll the left sidebar all the way down to Developer settings
        1. Token settings: Personal access tokensTokens (classic)Generate new token (classic)
        • 截圖 2026-09-01 下午2.53.33.png
          • Developer settings → Personal access tokens → Tokens (classic) → Generate new token → Generate new token (classic) — it really is buried deep
        • 截圖 2026-09-01 下午2.57.01.png
          • Turning on scopes sometimes triggers identity verification — check your inbox for “[GitHub] Sudo email verification code” and copy the 8-digit code
    • 2-4 Fill in the 3 fields on the token screen

      • FieldWhat to enter
        1 Note — just a label so you remember what it’s forn8n-wiki
        2 Expiration — how long the robot is allowed to use it90 days works, or set no expiration
        3 Select scopes — what the robot is allowed to doCheck repo only
      • 截圖 2026-09-01 下午3.00.32.png
        • Fill in those 3 fields as shown — checking repo auto-checks its sub-permissions
      • Scroll to the bottom of the page 截圖 2026-09-01 下午3.06.28.png​ and click Generate token.
    • 2-5 Send it to yourself immediately

      • A string starting with ghp_ appears. It is shown exactly once.
        • 截圖 2026-09-01 下午3.15.51.png
          • This is the token — the equivalent of another site’s API key. Close the page and it’s gone. Click the copy icon on the right and send it to yourself over a private channel (email, a messaging app) so you can find it again from another computer or phone.
      • ⚠️ This string is the water meter for your account — anyone who has it can act as you. Don’t paste it into a file, don’t let it show up in a screenshot, don’t share it with anyone. Missed copying it before closing the page? No problem — go back to the same screen, delete that token, and generate a new one.


  • n8n.webp​ @n8n | Step 3 — Paste it back into n8n

    • Switch back to the n8n tab.
    • FieldWhat to enter
      Server🚫 leave as is
      Useryour username
      Access Tokenthe ghp_ string
      Allowed HTTP Request Domains🚫 leave as is
    • Rename it next to the cat icon in the top left, then click Save. A green “Connection tested successfully” message means you’re done.
      • 截圖 2026-09-01 下午3.30.22.png
        • Fill in User and Access Token, leave everything else alone, click save — a green box means success
    • Didn’t work? 1) Did you paste the whole token? 2) Is User your username (copied from under your avatar), not your email?


  • FAQ

    • Does the token expire? Yes. Once it does, n8n starts throwing errors — go back and generate a new one to replace it.
    • Can one credential serve multiple workflows? Yes, unlimited — just pick the same one each time.
    • What can this key do? Anything your GitHub account can do. Keep it safe.


📚 相關文章