These examples are strict real-service proofs for the GitHub REST API surface in this package.
The normal request surface is generated through the shared pristine
runtime/codegen stack. For paginated endpoints, the generated modules also
expose stream_* helpers such as
GitHubEx.Repos.stream_list_for_authenticated_user/3.
Read these first if you have not created credentials yet:
| Example | Endpoint | Minimal FG PAT requirement | Notes |
|---|---|---|---|
00_smoke.exs |
GET / and GET /rate_limit |
none | no auth required for the smoke path |
01_get_authenticated_user.exs |
GET /user |
none | endpoint page says a fine-grained PAT needs no permissions |
02_list_authenticated_repos.exs |
GET /user/repos |
Metadata: read |
choose your own user as resource owner for /user and /user/repos |
03_list_repo_issues.exs |
GET /repos/{owner}/{repo}/issues |
Issues: read |
select the target repository on the token |
04_list_pull_requests.exs |
GET /repos/{owner}/{repo}/pulls |
Pull requests: read |
select the target repository on the token |
05_list_workflow_runs.exs |
GET /repos/{owner}/{repo}/actions/runs |
Actions: read |
select the target repository on the token |
Create a fine-grained PAT for the bundled read-focused examples:
- Choose your current user as resource owner when you want
/userand/user/repos. - Choose only the selected repositories you will test.
- Add exactly these repository permissions:
Metadata: readIssues: readPull requests: readActions: read
Contents: read is not required for the bundled examples.
If you want to try endpoints outside this read-focused surface, stop and read the Auth Capability Matrix before you assume the same token will work.
General:
export GITHUB_TOKEN="..."
export GITHUB_EXAMPLE_OWNER="octocat"
export GITHUB_EXAMPLE_REPO="Hello-World"
export GITHUB_EXAMPLE_ISSUE_NUMBER="1"Optional workflow example override:
export GITHUB_EXAMPLE_WORKFLOW_ID="ci.yml"OAuth examples:
export GITHUB_OAUTH_CLIENT_ID="..."
export GITHUB_OAUTH_CLIENT_SECRET="..."
export GITHUB_OAUTH_REDIRECT_URI="http://127.0.0.1:40071/callback"
export GITHUB_OAUTH_AUTH_CODE="..."OAuth app minimum:
- Go to GitHub Settings -> Developer settings -> OAuth Apps.
- Create a new OAuth app.
- Fill the minimum fields:
- Application name: any clear local-test name
- Homepage URL: any valid URL you control
- Authorization callback URL:
http://127.0.0.1:40071/callback - Enable Device Flow: leave unchecked
- Copy the client ID and client secret.
- Export
GITHUB_OAUTH_CLIENT_ID,GITHUB_OAUTH_CLIENT_SECRET, andGITHUB_OAUTH_REDIRECT_URI. - Run
mix github.oauth --save --manual --no-browser. - Open the printed authorize URL, approve access, and paste back the returned code.
This repo uses the normal authorization-code flow, not Device Flow.
GitHub App example:
export GITHUB_APP_ID="..."
export GITHUB_APP_PRIVATE_KEY_PATH="/path/to/private-key.pem"
export GITHUB_APP_INSTALLATION_ID="..."GitHub App minimum:
- Go to GitHub Settings -> Developer settings -> GitHub Apps.
- Create a new GitHub App.
- Fill only the minimum fields:
- GitHub App name: any unique local-test name
- Homepage URL: any valid URL you control
- Callback URL: leave blank for this example
- Expire user authorization tokens: leave off
- Request user authorization during installation: leave off
- Enable Device Flow: leave off
- Setup URL: leave blank
- Installation target:
Only on this accountis fine for local testing
- For permissions, start with
Repository metadata: Read-only. - Generate and download a private key
.pemfile. - Click
Install Appin the GitHub App UI and install it on the target account or org. - Copy the App ID from the app settings page.
- Copy the installation ID from the installation page URL. It is the number in
/settings/installations/<id>. - Export
GITHUB_APP_ID,GITHUB_APP_PRIVATE_KEY_PATH, andGITHUB_APP_INSTALLATION_ID.
Fastest first run:
mix run examples/00_smoke.exsThat public smoke example does not require GITHUB_TOKEN.
The suite runner is stricter:
./examples/run_all.sh smokerequiresGITHUB_TOKENbecause it also runs01_get_authenticated_user.exs./examples/run_all.sh allrequiresGITHUB_TOKENbefore it reaches the repo, OAuth, and app examples./examples/run_all.sh reposalso needsGITHUB_EXAMPLE_OWNERandGITHUB_EXAMPLE_REPO
Single example:
mix run examples/00_smoke.exs
mix run examples/03_list_repo_issues.exs
mix run examples/07_oauth_exchange_code.exsSuites:
./examples/run_all.sh smoke
./examples/run_all.sh repos
./examples/run_all.sh oauth
./examples/run_all.sh app
./examples/run_all.sh allRun examples from the repo root with mix run, or use run_all.sh.
00_smoke.exs:meta/rootandrate-limit/get01_get_authenticated_user.exs:users/get-authenticated02_list_authenticated_repos.exs:repos/list-for-authenticated-user03_list_repo_issues.exs:issues/list-for-repo04_list_pull_requests.exs:pulls/list05_list_workflow_runs.exs:actions/list-workflow-runs-for-repo06_oauth_authorize_url.exs: build a real GitHub OAuth URL07_oauth_exchange_code.exs: exchange a real OAuth authorization code08_github_app_auth.exs: sign a GitHub App JWT into a runtime client and exchange an installation token