Generate user access tokens (ghu_) via the OAuth Device Flow — ideal
for CLI apps, no web server needed.
Warning
These scripts are for demonstration and testing purposes only. Do not use in production. The scripts print the access token to stdout which may expose it in logs or shell history.
Python:
python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt
python device_flow.py --client-id YOUR_CLIENT_IDNode.js: (no dependencies!)
node device_flow.js --client-id YOUR_CLIENT_IDGo: (no dependencies!)
go run device_flow.go --client-id YOUR_CLIENT_IDShell: (requires curl + jq)
./device_flow.sh --client-id YOUR_CLIENT_ID| Guide | Description |
|---|---|
| Setup GitHub App | Create and configure a GitHub App for Device Flow |
| Python | Setup and usage for Python script |
| Node.js | Setup and usage for Node.js script |
| Go | Setup and usage for Go script |
| Shell | Setup and usage for Shell script |
| Common Issues | Troubleshooting and token usage |
- A GitHub App with Device Flow enabled (setup guide)
- Script requests a device code from GitHub
- You visit
github.com/login/deviceand enter the displayed code - Script polls until you authorise
- You get a user access token (
ghu_...) that acts on your behalf
GitHub Apps define permissions in the App's settings (Permissions & events), not at authorisation time. This differs from OAuth Apps where you request scopes in the OAuth request.