This guide explains how to set up and use GitHub integration with Nia AI, allowing secure access to your private repositories.

Overview

Nia AI supports seamless integration with GitHub, enabling you to:

  • Access and index private repositories

  • Maintain secure authentication

  • Manage repository permissions

  • Handle real-time updates

Authentication Flow

1

Install GitHub App

  1. Navigate to your Nia AI dashboard

  2. Click “Connect GitHub” button

  3. You’ll be redirected to GitHub’s authorization page

2

Grant Permissions

Select the repositories you want to give Nia AI access to:

  • Choose specific repositories

  • Or grant access to all repositories

3

Verify Installation

After installation, Nia AI will:

  1. Generate a unique installation token

  2. Validate the connection

  3. Show connected repositories in your dashboard

Repository Access

// GET /github/list-repos
const response = await fetch('/github/list-repos?user_id=YOUR_USER_ID');
const repos = await response.json();

Security Model

API Reference

List Repositories

GET /github/list-repos
endpoint

Returns a list of repositories the user has granted access to.

Save Installation

POST /user/github/installation
endpoint

Saves a new GitHub App installation for a user.

Uninstall App

POST /user/github/uninstall
endpoint

Removes a GitHub App installation.

Error Handling

Common Error Codes

CodeDescriptionSolution
401Invalid installation tokenRefresh token or reinstall app
403Repository access deniedCheck repository permissions
404Repository not foundVerify repository exists and is accessible
422Invalid repository formatUse owner/repo format

Best Practices

Repository Access

  • Grant access only to needed repositories

  • Regularly review repository permissions

  • Remove unused repository access

Security

  • Never share installation tokens

  • Use branch protection rules

  • Monitor GitHub audit logs

Troubleshooting

FAQ