OpenClaw + GitHub

GitHub Setup Guide for OpenClaw

A clean walkthrough for connecting OpenClaw to GitHub, fixing token permissions, and confirming working write access.

This guide documents exactly what we did to let OpenClaw access and modify the GitHub repository danielgesd32/agent-creation.

  • Access GitHub from the OpenClaw agent session
  • Authenticate with the GitHub API
  • Read repository metadata
  • Create files and folders in the repository

1. Confirm GitHub was reachable

First, we verified that GitHub itself was reachable from the agent environment.

Tested URLs:

  • https://github.com
  • https://github.com/danielgesd32/agent-creation

This confirmed network access was working.

2. Identify the real problem

The initial issue was not GitHub connectivity. The real issue was that the running OpenClaw service did not have a GitHub token loaded in its environment.

We checked for environment variables like:

  • GITHUB_TOKEN
  • GH_TOKEN

At first, none were available in the active agent session.

3. Add the GitHub token to the OpenClaw systemd user service

OpenClaw was running as a user systemd service, so the token needed to be added there.

systemctl --user edit openclaw-gateway.service

In the override file, we added:

[Service]
Environment="GITHUB_TOKEN=YOUR_REAL_GITHUB_TOKEN"

If needed, other environment variables can also live there:

Environment="DISCORD_BOT_TOKEN=YOUR_REAL_DISCORD_TOKEN"
Important: use the real token value, not a placeholder like github_TOKEN_HERE.

4. Reload and restart the service

After saving the override, reload systemd and restart OpenClaw:

systemctl --user daemon-reload
systemctl --user restart openclaw-gateway.service

5. Verify the service actually had the token

We checked whether the service environment included the token:

systemctl --user show openclaw-gateway.service --property=Environment

A safe version for sharing is:

systemctl --user show openclaw-gateway.service --property=Environment | sed 's/GITHUB_TOKEN=[^ ]*/GITHUB_TOKEN=[redacted]/g'

We also checked service status:

systemctl --user status openclaw-gateway.service --no-pager

6. Test authenticated GitHub API access

Once the token was loaded, we tested the GitHub API against the repository danielgesd32/agent-creation.

The authenticated API test confirmed:

  • repository name
  • visibility
  • default branch
  • token-backed access to repository metadata
Successful result
  • repo: danielgesd32/agent-creation
  • visibility: public
  • default branch: main

7. First write attempt failed

When we tried to create a file in the repository through the GitHub API, GitHub returned:

403 Resource not accessible by personal access token

This showed that the token could read repo metadata, but it did not have permission to write repository contents.

8. Fix GitHub token permissions

The token was a Fine-grained personal access token. The missing permission was:

  • Contents: Read and write

Correct GitHub token settings

Repository access

  • All repositories
  • or only selected repositories including agent-creation

Repository permissions

  • Contents → Read and write
  • Metadata stays enabled
  • Administration alone is not enough

9. Retry file creation after the permission fix

After updating the token permissions, we tested again by creating a placeholder file:

test-folder/.gitkeep
Success
  • HTTP 201
  • Created file: test-folder/.gitkeep
  • Commit: 3c59ca9a03a2e1b5cdd9bde14655fcd0b9a1b04e

This confirmed the token now had working write access.

Commands reference

systemctl --user edit openclaw-gateway.service
systemctl --user daemon-reload
systemctl --user restart openclaw-gateway.service
systemctl --user status openclaw-gateway.service --no-pager
systemctl --user show openclaw-gateway.service --property=Environment
systemctl --user show openclaw-gateway.service --property=Environment | sed 's/GITHUB_TOKEN=[^ ]*/GITHUB_TOKEN=[redacted]/g'

Security notes

  • Do not share your real GITHUB_TOKEN publicly.
  • If a token is exposed accidentally, rotate or regenerate it.
  • Fine-grained tokens are safer than broad classic tokens when you only need limited repo access.
  • Grant only the permissions you actually need.

Hostinger deployment

This repo is already structured as a simple static website. To publish it on Hostinger, upload the website files from the repository root:

  • index.html
  • styles.css

If you want, you can also keep the repo in GitHub and download it as a ZIP for uploading into Hostinger's File Manager.