# How to Configure a GitHub Token for Private Repositories Access in Agent-Reach

> Easily configure your GitHub token for Agent-Reach to access private repositories. Use the CLI or manually edit the config YAML for seamless integration.

- Repository: [Pnant/Agent-Reach](https://github.com/Panniantong/Agent-Reach)
- Tags: how-to-guide
- Published: 2026-07-17

---

**Use the `agent-reach configure github-token <token>` CLI command to store your token in `~/.agent-reach/config.yaml`, or manually edit the YAML configuration file to set the `github_token` key.**

Agent-Reach requires a GitHub personal access token to fetch data from private repositories. This token is stored securely in a local configuration file and used by the CLI whenever it needs to access protected repository data. Learning how to configure GitHub token for private repositories access ensures the tool can authenticate with GitHub's API on your behalf.

## Generating a GitHub Personal Access Token

Before configuring Agent-Reach, you must generate a token from your GitHub account settings.

1. Navigate to **GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)**.
2. Click **Generate new token** and select **Generate new token (classic)**.
3. Provide a descriptive name such as "Agent-Reach Access".
4. Select the **repo** scope to enable access to private repositories.
5. Click **Generate token** and copy the value immediately (it will only be shown once).

## Method 1: Configure via CLI

The recommended approach uses the built-in `configure` command, which handles validation and storage automatically.

When you run `agent-reach configure github-token <YOUR_TOKEN>`, the CLI invokes the `config.set("github_token", value)` method in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (lines 1122-1124). This writes the token to your local configuration file at `~/.agent-reach/config.yaml`.

```bash

# Set your GitHub token using the CLI

agent-reach configure github-token ghp_XXXXXXXXXXXXXXXXXXXXXXXXXX

```

This method is preferred because it ensures the YAML syntax remains valid and the token is properly escaped.

## Method 2: Manual Configuration

You can also edit the configuration file directly using a text editor. This is useful for automation scripts or when you need to modify the file without running the CLI.

Open `~/.agent-reach/config.yaml` in your preferred editor:

```bash
nano ~/.agent-reach/config.yaml

```

Add or update the `github_token` entry:

```yaml
github_token: ghp_XXXXXXXXXXXXXXXXXXXXXXXXXX

```

The [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py) module handles reading this value via `Config.get("github_token")` when the application needs to authenticate with GitHub.

## Verification

To confirm your token is properly stored, you can either inspect the configuration file or test access to a private repository.

Check the configuration file contents:

```bash
cat ~/.agent-reach/config.yaml | grep github_token

```

You should see output matching your token value:

```yaml
github_token: ghp_XXXXXXXXXXXXXXXXXXXXXXXXXX

```

Alternatively, attempt to access a private repository using Agent-Reach. If the token is valid, the tool will successfully retrieve repository data without authentication errors.

## Summary

- **Primary storage location**: The GitHub token is stored in `~/.agent-reach/config.yaml` under the `github_token` key.
- **CLI method**: Run `agent-reach configure github-token <token>` to automatically save the token (implemented in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py), lines 1122-1124).
- **Manual method**: Edit the YAML file directly to add the `github_token` field, which is read by [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py).
- **Scope requirements**: The token needs the **repo** scope to access private repositories.
- **Security**: Never commit the configuration file to version control; Agent-Reach stores it in your home directory to keep it separate from project files.

## Frequently Asked Questions

### Do I need specific scopes for the GitHub token?

Yes, you must select the **repo** scope when generating the token to grant Agent-Reach access to private repositories. For public repositories only, no scopes are required, but the **repo** scope is recommended for comprehensive access.

### Where is the GitHub token stored locally?

Agent-Reach stores the token in `~/.agent-reach/config.yaml` as a YAML key-value pair. The configuration is managed by the `Config` class in [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py), which handles both reading and writing to this file.

### Can I use environment variables instead of the config file?

The current implementation in [`agent_reach/cli.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/cli.py) (lines 1122-1124) and [`agent_reach/config.py`](https://github.com/Panniantong/Agent-Reach/blob/main/agent_reach/config.py) reads the token exclusively from the YAML configuration file. While the CLI provides the `configure github-token` command to set this value, direct environment variable support is not implemented in the core configuration handler.

### How do I update an existing GitHub token?

Run the `agent-reach configure github-token <new_token>` command again to overwrite the existing value in `~/.agent-reach/config.yaml`. Alternatively, manually edit the configuration file and replace the value associated with the `github_token` key, then save the file.