Skip to content
Grace Muthoni Kariuki

Dec 5, 202616 min read

You create a GitHub personal access token under Settings > Developer settings > Personal access tokens, and it authenticates API and Git requests as your account, whether those requests come from a script or from an automation tool like Activepieces.

The steps below follow GitHub's own documentation on managing personal access tokens, checked on 5 December 2026.

A GitHub personal access token is a revocable, scoped credential that you generate in your account settings and use in place of a password to authenticate Git operations and GitHub API requests as you.

Before you click anything, settle who owns this token: it acts as you, so whatever it can reach, you're answerable for.

Choose the fine-grained type first; it's the one that lets you limit access to named repositories.

Create your GitHub personal access token

  1. Open your profile menu, choose Settings, then Developer settings at the bottom of the left sidebar.
  2. Under Personal access tokens, choose Fine-grained tokens, then Generate new token.
  3. Enter a token name that says what it's for, such as the name of the automation that will use it.
  4. Set an expiration. Pick the shortest period you can live with, because an expiry date is your rotation schedule.
  5. Set the resource owner (your account or an organisation), then under Repository access choose Only select repositories and pick them by name.
  6. Under Permissions, add only what the task needs, such as read-only access to Contents or read and write access to Issues, then choose Generate token and copy it once. GitHub doesn't show it again.

A GitHub Settings page with a left sidebar menu where Developer settings sits at the bottom, and a Generate new token…

Classic token steps and when they are still needed

In Tokens (classic), under the same Developer settings menu, you choose a note, an expiration and a set of scopes such as repo. Those scopes are broad: repo reaches every repository your account can, which is the exposure the fine-grained type removes.

Use a classic token only when a tool or an endpoint you depend on doesn't yet accept fine-grained tokens, and record that exception against the token's owner.

What the account, plan and organisation must allow

You need a GitHub account with a verified sign-in. For repositories owned by an organisation, the organisation's owners decide whether fine-grained tokens may access its resources, and they may require approval before a token takes effect.

If your token returns not-found or forbidden errors on an organisation repository, ask the owner about that policy before you widen the token's permissions.

Yes: a free account can create tokens and call the GitHub API with them, subject to the API's rate limits. Some features a token reaches may depend on your plan or the repository's visibility, so check the endpoint's documentation rather than assuming it's available.

Creating a project variable

This takes minutes, not a project: automate it in Activepieces free.

Fine-grained versus classic tokens: what each can access

Choose fine-grained and the token reaches only the repositories and permissions you grant it. A classic token reaches everything its scope allows across every repository you can see, and a GitHub App token belongs to an installation rather than to a person.

The table below sets out which of these a given endpoint accepts, and which one GitHub's documentation recommends. Read it as a checklist: pick the row that matches the job, then confirm the endpoint supports that token type.

Fine-grained PAT Classic PAT GitHub App token
Scope model Chosen repositories, plus individual permissions per resource Broad scopes covering all repositories the user can access Permissions set on the app, limited to the repositories where it is installed
Expiry rules Expiry is configurable, up to 1 year or no expiration. Expiry is optional Installation tokens are short-lived and are reissued by the app
Organisation approval An organisation can require approval before the token reaches its resources Organisation owners can restrict classic tokens, and SSO-enforced organisations require the token to be authorised An owner approves the installation of the app
Endpoint coverage Most REST endpoints, with gaps Widest coverage of the three for user-owned access Endpoints that support app authentication
When the docs recommend it The default choice for personal scripts and automation A fallback when a fine-grained token does not cover what you need Preferred for integrations that should not depend on one person

Read across the rows and you see a trade between reach and control. The further right you read for coverage, the less tightly the token matches what you intended.

Permissions and repository access

You bind a fine-grained token to one resource owner, either your account or a single organisation, and you name the repositories it may touch. Within those, you grant each permission separately, such as read-only access to contents or write access to issues.

With a classic token there is no such boundary: a single repo scope applies to every repository the account can reach, including private ones.

When you review a connection, ask first who owns the token and which repositories it names. A classic token usually can't answer either question narrowly.

If a call returns an error for a token that seems correctly permissioned, check the endpoint's own page for its list of supported token types before widening anything. GitHub's documentation notes that some endpoints don't work with fine-grained tokens.

Admin dashboard showing AI usage metrics, spending by source, project costs, and AI model usage breakdown with charts and…

GitHub token expiry and organisation policies

Because fine-grained tokens can be given an expiry of up to 1 year, a token with an expiry carries a handover date. That's useful: it forces a decision about whether the connection is still needed and who will replace it. You can create a classic token with no expiry, so a forgotten token keeps working indefinitely.

Expect a wait when an organisation requires approval for fine-grained tokens: a new token may sit pending until an owner reviews it. Plan for that delay when you wire a token into an automation.

When a GitHub App is the better choice

Use a GitHub App when the integration should outlive the person who set it up, or when you need endpoints that fine-grained tokens don't cover but that apps support.

The app, not an individual, owns the access, and its installation tokens are short-lived. That removes the question of whose account is behind the connection.

You pay in setup: you register the app, have it installed, and generate tokens in code, so a personal script rarely justifies it.

Minimal GitHub API request with token

For a personal script, one request with three headers is enough: send GET https://api.github.com/user with your token, and a correct setup returns your account's details. The request is the same whether the token is fine-grained or classic.

A terminal window showing a GET request to api.github.com/user with an Authorization header, and below it a JSON response…

curl -L \
 -H "Authorization: Bearer $GITHUB_TOKEN" \
 -H "Accept: application/vnd.github+json" \
 -H "X-GitHub-Api-Version: 2022-11-28" \
 https://api.github.com/user

Read the token from an environment variable, as above, so it never sits in the command history or the file. A status of 200 with a JSON body containing your login means GitHub accepted the token and identified its owner.

A 401 means the token was missing, mistyped, expired or revoked. Fix the token before debugging anything else.

Create an issue as a first write call

Once a read has proved identity, a write is what proves the scope you chose. Pick a repository the token covers, and send:

curl -L -X POST \
 -H "Authorization: Bearer $GITHUB_TOKEN" \
 -H "Accept: application/vnd.github+json" \
 -H "X-GitHub-Api-Version: 2022-11-28" \
 https://api.github.com/repos/OWNER/REPO/issues \
 -d '{"title":"Token check","body":"Created to confirm write access."}'

This needs the fine-grained permission "Issues" set to read and write on that repository. Success is a 201 with the new issue's number and URL, so the issue exists and the token can write there.

When you get a 404 on a repository you can see, the token usually wasn't granted that repository, since GitHub hides what a token can't reach. A 403 usually means the permission is read-only.

Run the same call against a repository outside the token's list and expect it to fail. That failure shows the narrow scope works.

In an automation tool's run log, an authenticated POST has the same shape: the method, the Authorization header, a 200 response. It confirms GitHub accepted the credential and the call went through. The remaining question is how much of your allowance each call uses.

A workflow automation interface showing the execution and configuration of an HTTP request that revokes an API token using…

Nothing is charged per call, but limits depend on the plan and on how the request is authenticated, and every response carries the current state in its headers:

  • x-ratelimit-limit: the allowance for this window.
  • x-ratelimit-remaining: calls left before throttling.
  • x-ratelimit-reset: when the window resets, as a Unix timestamp.
  • x-ratelimit-resource: which pool the call counted against.

Check x-ratelimit-remaining in loops and back off before it reaches zero. A 403 or 429 with remaining at zero is throttling, not a permissions fault, and waiting until the reset time clears it.

A small dashboard with a x-ratelimit-remaining gauge near zero and a x-ratelimit-reset clock beside it, next to a loop of…

You can follow the rest of this with the builder open. Start free, no card.

GitHub API rate limits and token errors

5,000 REST requests an hour: that is what a personal access token gets, against 60 for an unauthenticated caller, so sending the token is the first fix for a script that stalls early.

The figures below were checked on 2026-12-05 against GitHub's REST rate-limit page.

GitHub API primary and secondary rate limits

Compare the hourly REST allowance by authentication type in the chart. A token is about eighty times better off than an anonymous caller, and a GitHub App installation matches it at 5,000 while an App on Enterprise rises to 15,000.

GitHub's hourly REST request allowance by authentication type

After the chart comes the practical point: every token you own shares one allowance, so a nightly sync and a busy automation draw on the same 5,000.

If you need more than that, the owner of the connection should move the workload to an App instead of creating a second token. The 15,000 figure applies only to Apps on Enterprise, not to personal tokens at any plan.

Separate from all of that are the secondary limits. They govern bursts and concurrent requests, not the hourly total, so you can hit one with requests remaining.

When a private resource is out of the token's sight, GitHub deliberately returns 404, so a 404 is often a permissions problem.

Status Likely cause Fix
401 Token expired, revoked or mistyped Generate a new token and update the stored secret
403 Token lacks the permission, or a limit was hit Check the token's permissions, then the rate-limit headers
404 on a private repo Repository not selected for a fine-grained token Add the repository to the token's list
429 Primary or secondary limit exceeded Wait, then retry
Wrong resource owner Token created under your user, repo belongs to an organisation Recreate the token with the organisation as resource owner
SSO not authorised Organisation enforces single sign-on Authorise the token for that organisation

Read the response headers before retrying: if retry-after is present, wait that many seconds, and if x-ratelimit-remaining is 0, wait until the time in x-ratelimit-reset. A 403 with remaining requests is a permissions fault, and retrying won't help.

Keep your GitHub token out of code

Once the 403s are sorted and the token works, keep it out of every file you commit and every page a browser loads. Store it in an environment variable, a secrets manager or Actions secrets.

Just over 6 million new secrets were detected in public GitHub commits in 2021, 10 million in 2022 and 12,778,599 in 2023. That scale is the reason.

At that scale, a credential committed by accident is a routine event, and automated scanners will find yours. The rest of this section assumes the slip will happen and limits what it costs.

Activepieces supports secret managers as part of its enterprise governance features, on self-hosted Enterprise and on the Ultimate cloud tier, so credentials can be held centrally.

That secret-manager integration sits in the enterprise governance feature set next to SCIM, custom RBAC, SSO/SAML and audit logs, and MoneyGram, Moneypenny, Alan and FundingSocieties run Activepieces in production.

Where the token should live

Name an owner for the token before you store it: one person or team who can rotate it and who is told when it's revoked. Then pick the place by where the code runs.

For local development, use an environment variable loaded from a .env file that's listed in .gitignore. Never commit that file.

For deployed services, use a secrets manager, read at start-up, so the value never appears in the image or the repository.

In GitHub Actions, use an Actions secret at repository, environment or organization level, referenced as ${{ secrets.NAME }}. For work inside the same repository, prefer the workflow's built-in GITHUB_TOKEN with an explicit permissions block over a personal token.

In browser or mobile code, put the token nowhere. Anything shipped to a client can be read by its user, so route the call through a server that holds the token.

Turn on secret scanning and push protection for the repositories you own. Per GitHub's documentation, push protection checks a push for supported secret patterns and can block it before the token reaches the repository history.

Rotating and revoking a token

Set an expiry when you create a fine-grained token. A token that lapses on its own limits how long a forgotten copy stays useful. Keep the permissions and repository list minimal, because that decides what a stolen copy can do.

Because the application reads the token from one named variable or secret, rotation means generating a new token, replacing that one value and revoking the old token. No code changes.

Record the expiry date and the owner next to the secret's name so the renewal isn't a surprise.

Revoke first, investigate second. Deleting the token in GitHub's settings ends its access immediately, whereas removing the commit doesn't, because the value stays in history, forks and caches. After revoking:

  1. Check the account's security log and the repositories the token could reach for activity you didn't make.
  2. Issue a replacement with the same narrow scope.
  3. Store the replacement in the secret location, not the file where the leak happened.
  4. Record who owned the token, how it escaped and which control would have caught it.

Use a GitHub token in Activepieces without code

Paste the fine-grained token once as the connection in the GitHub integration, one of the 751 integrations counted in the Activepieces open source monorepo, so most tools you'll want to connect are probably already integrated.

Every flow that uses that connection acts with exactly the repository access you granted, no more.

That suits automations that run on a schedule or an event rather than direct scripts where you would read the token from an environment variable yourself, and flows are unlimited on every plan, including free, so a nightly sync and an event-driven flow don't compete for a quota.

A workflow execution interface showing a completed two-step Square OAuth token revocation flow with HTTP configuration

If that person leaves or revokes the token, every flow using the connection fails, so ownership comes first.

The token belongs to the GitHub account that issued it, so name an owner for it and for the connection before you build anything. The free plan allows up to 5 users, which keeps that list short.

Look at the builder to see how steps are chosen: a flow starts with a trigger, here a schedule trigger labeled "1. Every Hour", then passes through action steps such as "2. Ask ChatGPT" to an "End" node.

Activepieces workflow builder showing a test flow connecting an Every Hour schedule trigger to an Ask ChatGPT action, with…

Type "sheet" into the "Select Step" dialog on the right and it filters by name, returning Microsoft Excel 365, Google Sheets and AITable, each as its own integration.

Take from this that an integration is a self-contained integration you search for and add. Search "GitHub" the same way and you get the GitHub integration.

Add the connection

Add a GitHub step to the flow, open its connection field and choose to create a new connection. Paste the token into the credential field and save.

Rotating the token later means editing this one connection rather than every step, and because the core is MIT-licensed, the code that handles the connection is open for you to read in the repository.

Because the token is limited to specific repositories, a step pointed at any other repository will return a not-found or permission error. Read that as the scope working, not as a fault.

Pick a trigger, either the schedule trigger shown above or a GitHub trigger the integration lists, then add one GitHub action that reads rather than writes.

Use the builder's test button on that step and check the output. A read-only first run proves the token reaches the repository without risking a change to it.

Monday steps:

  1. Create a fine-grained token with a 30-day expiry, limited to the repositories the flow needs.
  2. Test it with a GET request to /user and confirm you receive your account back, not a 401.
  3. Store it as the Activepieces connection, record who owns it, and put the expiry date in a calendar.

References

Share

Build it

Set this up in minutes.

No code required. Connect your accounts, and Activepieces runs it from there.

Start free Talk to sales