注意
Consider building a GitHub App instead of an OAuth app.
Both OAuth apps and GitHub Apps use OAuth 2.0.
OAuth apps can only act on behalf of a user while GitHub Apps can either act on behalf of a user or independently of a user.
GitHub Apps use fine-grained permissions, give the user more control over which repositories the app can access, and use short-lived installation access tokens.
For more information, see GitHub 应用和 OAuth 应用之间的差异 and 关于创建GitHub应用.
注意
A user or organization can own up to 100 OAuth apps.
Starting January 5, 2027, newly registered GitHub Apps and OAuth apps on GitHub.com will only support expiring user access tokens. For these apps, you can't disable token expiration during registration.
-
In the upper-right corner of any page on GitHub, click your profile picture, then click Settings.
-
In the left sidebar, click Developer settings.
-
In the left sidebar, click OAuth apps.
-
Click New OAuth App.
注意
If you haven't created an app before, this button will say, Register a new application.
-
In "Application name", type the name of your app.
警告
Only use information in your OAuth app that you consider public. Avoid using sensitive data, such as internal URLs, when creating an OAuth app.
-
In "Homepage URL", type the full URL to your app's website.
-
Optionally, in "Application description", type a description of your app that users will see.
-
In "Authorization callback URL", type the callback URL of your app.
You can enter up to 10 callback URLs. To add additional callback URLs, click Add callback URL.
-
If your OAuth app will use the device flow to identify and authorize users, click Enable Device Flow. For more information about the device flow, see 授权 OAuth 应用.
-
If Expire user access tokens is available, it is enabled by default. You can deselect Expire user access tokens if your app's authentication code hasn't been updated to support short-lived tokens. For more information about expiring tokens, see 授权 OAuth 应用.
-
Click Register application.