Creating a GitHub token

The extension commits to your repository on your behalf, so it needs a personal access token with permission to write files. This takes about a minute.

Two kinds of token exist. A fine-grained token can be locked to a single repository, which is what we recommend. A classic token is quicker but grants access to everything you own. Both work.

Fine-grained token (recommended)

  1. Open the token page Go straight to github.com/settings/personal-access-tokens/new. You can also reach it through your profile picture, then Settings, Developer settings, Personal access tokens, Fine-grained tokens.
  2. Name it and set an expiry Something like LeetCode Uploader. Any expiry works. When it lapses the extension will tell you the token expired, and you repeat these steps.
  3. Pick the repository Under Repository access, choose Only select repositories and select the repo you want your solutions committed to. If the repo belongs to an organisation, set Resource owner to that organisation first.
  4. Grant write access to files Open Repository permissions, find Contents, and set it to Read and write. That single permission is all the extension uses. Metadata: Read-only is added automatically and cannot be removed.
  5. Generate and copy it Press Generate token. The token starts with github_pat_ and is shown exactly once, so copy it before leaving the page.
  6. Paste it into the extension Click the extension icon, paste the token, and press Connect. It will confirm which account it connected as.
If your repository is owned by an organisation Fine-grained tokens may need an organisation owner to approve them before they work. Until that happens the extension reports that it cannot see the repository.

Classic token

If you would rather use a classic token, or your setup requires one:

  1. Open the classic token page Go to github.com/settings/tokens/new.
  2. Tick the repo scope Under Select scopes, check repo. This grants access to all of your repositories, which is why the fine-grained option is preferable.
  3. Generate and copy it Classic tokens start with ghp_ and are also shown only once.

Keeping the token safe

If it does not work

The extension says Cause
That token is invalid or has expired The token was mistyped, revoked, or has passed its expiry date. Generate a new one.
Cannot see owner/repo The repository was not included under Repository access, or an organisation has not approved the token yet.
Your token can read this repo but not write to it Contents is set to Read-only. Change it to Read and write.