Skip to content

Commit 6dfdd48

Browse files
committed
Update README
1 parent ee32595 commit 6dfdd48

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,18 @@ This tap accepts the following configuration options:
3838
- `auth_token` - Takes a single token.
3939
- `additional_auth_tokens` - Takes a list of tokens. Can be used together with `auth_token` or as the sole source of PATs.
4040
- Any environment variables beginning with `GITHUB_TOKEN` will be assumed to be PATs. These tokens will be used in addition to `auth_token` (if provided), but will not be used if `additional_auth_tokens` is provided.
41-
- GitHub App keys are another option for authentication, and can be used in combination with PATs if desired. App IDs and keys should be assembled into the format `:app_id:;;-----BEGIN RSA PRIVATE KEY-----\n_YOUR_P_KEY_\n-----END RSA PRIVATE KEY-----` (replace `:app_id:` with your actual GitHub App ID and `_YOUR_P_KEY_` with your private key content) where the key can be generated from the `Private keys` section on https://github.com/organizations/:organization_name/settings/apps/:app_name. Read more about GitHub App quotas [here](https://docs.github.com/en/enterprise-server@3.3/developers/apps/building-github-apps/rate-limits-for-github-apps#server-to-server-requests). Formatted app keys can be provided in 2 ways:
42-
- `auth_app_keys` - List of GitHub App keys in the prescribed format.
43-
- If `auth_app_keys` is not provided but there is an environment variable with the name `GITHUB_APP_PRIVATE_KEY`, it will be assumed to be an App key in the prescribed format.
41+
- GitHub App keys are another option for authentication, and can be used in combination with PATs if desired. App IDs and keys should be assembled into the format `:app_id:;;-----BEGIN RSA PRIVATE KEY-----\n_YOUR_P_KEY_\n-----END RSA PRIVATE KEY-----` (replace `:app_id:` with your actual GitHub App ID and `_YOUR_P_KEY_` with your private key content) where the key can be generated from the `Private keys` section on https://github.com/organizations/:organization_name/settings/apps/:app_name. Read more about GitHub App quotas [here](https://docs.github.com/en/enterprise-server@3.3/developers/apps/building-github-apps/rate-limits-for-github-apps#server-to-server-requests). Formatted app keys can be provided in 3 ways:
42+
- `auth_app_keys` (array format) - List of GitHub App keys in the prescribed format. These keys are organization-agnostic and will be used for all organizations.
43+
- `auth_app_keys` (object format) - Object/dictionary mapping organization names to lists of GitHub App keys. This allows you to specify different app credentials for different organizations, enabling better rate limit management across multiple organizations. Example:
44+
```yaml
45+
auth_app_keys:
46+
org1:
47+
- "app_id_1;;-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
48+
- "app_id_2;;-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
49+
org2:
50+
- "app_id_3;;-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
51+
```
52+
- If `auth_app_keys` is not provided but there is an environment variable with the name `GITHUB_APP_PRIVATE_KEY`, it will be assumed to be an App key in the prescribed format (organization-agnostic).
4453
- Optional:
4554
- `user_agent`
4655
- `start_date`
@@ -65,6 +74,16 @@ tap-github --about
6574

6675
A small number of records may be pulled without an auth token. However, a Github auth token should generally be considered "required" since it gives more realistic rate limits. (See GitHub API docs for more info.)
6776

77+
#### Multi-Organization Authentication
78+
79+
When using the object format for `auth_app_keys`, the tap will automatically switch authentication contexts based on the organization being processed. This enables:
80+
81+
- **Organization-specific rate limits**: Each organization can have its own set of GitHub App credentials, preventing rate limit exhaustion when processing multiple organizations.
82+
- **Automatic token selection**: When processing repositories from a specific organization, the tap will prefer tokens configured for that organization.
83+
- **Fallback behavior**: If no organization-specific tokens are available, the tap will fall back to:
84+
1. Organization-agnostic tokens (personal tokens or array-format app keys)
85+
2. Tokens from other organizations (for accessing public data)
86+
6887
## Usage
6988

7089
### API Limitation - Pagination

tap_github/authenticator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def __init__(
407407
expiry_time_buffer: int | None = None,
408408
auth_token: str | None = None,
409409
additional_auth_tokens: list[str] | None = None,
410-
auth_app_keys: list[str] | None = None,
410+
auth_app_keys: list[str] | dict[str, list[str]] | None = None,
411411
) -> None:
412412
"""Init authenticator.
413413
@@ -418,7 +418,9 @@ def __init__(
418418
app tokens. Only relevant when authenticating as a GitHub app.
419419
auth_token: A personal access token.
420420
additional_auth_tokens: A list of personal access tokens.
421-
auth_app_keys: A list of GitHub App keys.
421+
auth_app_keys: GitHub App keys in either array format (list of keys for
422+
all organizations) or object format (dict mapping organization names
423+
to lists of keys for org-specific authentication).
422424
"""
423425
super().__init__()
424426
self.rate_limit_buffer = rate_limit_buffer

0 commit comments

Comments
 (0)