OAuth Authentication
GitHub Desktop uses the OAuth web application flow to authenticate users and perform actions on their behalf.OAuth Scopes
The application requests the following OAuth scopes:repo- Full control of private repositoriesuser- Read/write access to profile infoworkflow- Update GitHub Action workflows
app/src/lib/api.ts
Client Credentials
For development and testing, GitHub Desktop includes bundled OAuth credentials. In production, you can provide your own:The bundled developer OAuth application will not work with GitHub Enterprise. You must provide your own credentials for Enterprise instances.
API Client
TheAPI class provides methods for interacting with GitHub’s REST API:
app/src/lib/api.ts
Authentication Keys
Account authentication keys are stored securely using the operating system’s credential manager:app/src/lib/auth.ts
Repository Operations
Fetching Repository Information
1
Fetch repository details
Use the
fetchRepository method to get repository metadata:2
Access repository properties
The response includes:
- Clone URLs (HTTPS and SSH)
- Default branch
- Fork status
- Permissions
- Archive status
3
Clone with preferred protocol
Creating Repositories
app/src/lib/api.ts
Pull Request Integration
Fetching Pull Requests
GitHub Desktop efficiently fetches pull requests using pagination:app/src/lib/api.ts
Incremental Updates
For repositories with many PRs, GitHub Desktop uses an intelligent pagination strategy that ramps up page size:app/src/lib/api.ts
Pull Request Details
The API provides comprehensive PR information:app/src/lib/api.ts
Issue Management
Fetching Issues
Retrieve issues with filtering by state and date:app/src/lib/api.ts
Fetching Comments
Check Runs and Status
Combined Status
Fetch the combined status for a commit reference:app/src/lib/api.ts
Check Runs
Retrieve GitHub Actions check runs:app/src/lib/api.ts
Branch Protection
Push Control
Check if a user can push to a protected branch:app/src/lib/api.ts
allow_actor is always true for repository admins, even if push restrictions are enabled.Repository Rules
Fetch repository rules that apply to a specific branch:creation- Branch creation rulesupdate- Update restrictionsrequired_status_checks- Required CI checkspull_request- PR requirementscommit_message_pattern- Commit message validationrequired_signatures- Signed commit requirements
Error Handling
The API includes comprehensive error handling and token invalidation callbacks:app/src/lib/api.ts
Related Documentation
Learn more about GitHub’s API in the GitHub REST API documentation.