This guide walks you through creating a GitHub App and configuring it for the OAuth Device Flow.
-
Go to your GitHub settings:
- Personal account: Settings → Developer settings → GitHub Apps
- Organization: Organization Settings → Developer settings → GitHub Apps
-
Click New GitHub App
-
Fill in the required fields:
- GitHub App name: A unique name (e.g.,
my-cli-tool) - Homepage URL: Your app's homepage (can be a GitHub repo URL)
- GitHub App name: A unique name (e.g.,
Even though Device Flow doesn't use a callback URL, one must be configured for the Device Flow option to work.
-
In the Callback URL field, enter:
http://localhost⚠️ Important: Without a Callback URL, you'll get a 404 error when visitinggithub.com/login/device.
- Look for Enable Device Flow checkbox (usually under "Post installation" or "Optional features" depending on your GitHub version)
- Check ✅ Enable Device Flow
Configure the permissions your app needs:
- Scroll to Permissions & events
- Expand Account permissions and/or Repository permissions
- Select the access level needed for each permission
Common permissions for user access tokens:
| Permission | Access | Use Case |
|---|---|---|
| Contents | Read | Read repository files |
| Metadata | Read | Basic repo info (usually required) |
| Pull requests | Read/Write | Create or manage PRs |
| Issues | Read/Write | Create or manage issues |
Under Where can this GitHub App be installed?:
- Only on this account: Restricts to your account/org only
- Any account: Allows anyone to install your app
For personal/internal tools, "Only on this account" is usually sufficient.
- Click Create GitHub App
- You'll be redirected to your new app's settings page
On your app's settings page, locate the Client ID:
App ID: 123456 ← Not this one!
Client ID: Iv23liXXXXXXXX ← Use this one!
Note
The Client ID (starts with Iv) is different from the App ID
(numeric). Device Flow uses the Client ID.
You must install the app before generating user tokens:
- Go to your app's settings page
- Click Install App in the left sidebar
- Select the account/organisation to install on
- Choose All repositories or Only select repositories
- Click Install
| Setting | Value |
|---|---|
| Callback URL | http://localhost (required) |
| Device Flow | ✅ Enabled |
| Client ID | Starts with Iv (not the numeric App ID) |
Once you configure your app, use the Client ID with any of the Device Flow scripts:
# Python
python device_flow.py --client-id YOUR_CLIENT_ID
# Node.js
node device_flow.js --client-id YOUR_CLIENT_ID
# Go
go run device_flow.go --client-id YOUR_CLIENT_ID
# Shell
./device_flow.sh --client-id YOUR_CLIENT_ID