This document will guide you through the steps to create and configure a GitHub OAuth application for using GitHub login functionality in your project.
- Log in to your GitHub account.
- Navigate to your developer settings page:
- Click on your profile avatar in the top right corner.
- Select Settings.
- In the left sidebar, select Developer settings.
- On the Developer settings page, select OAuth Apps, then click the New OAuth App button.
On the "Register a new OAuth application" page, you need to fill in the following information:
- Application name: Give your application a descriptive name, such as
Insforge Dev Login. - Homepage URL: Your application's homepage URL. In development environment, you can set it to
http://localhost:7130or your frontend development server address. - Application description (optional): Provide a brief description of your application.
- Authorization callback URL: This is the URL where GitHub will redirect users after authorization. For local development, make sure to set it to:
Note: This URL must exactly match the callback URL configured in your backend service, otherwise the OAuth flow will fail.
http://localhost:7130/api/auth/oauth/github/callback
After filling in the information, click Register application.
After creating the application, you will be redirected to the application's settings page. Here you can see the Client ID.
To get the Client Secret, click the Generate a new client secret button. GitHub will generate a secret and display it to you.
Important: The Client Secret will only be shown once. Please copy it immediately and keep it secure. If you lose it, you will need to generate a new one.
After obtaining the Client ID and Client Secret, you need to add them to your project's .env file. Make sure your .env file (or corresponding environment configuration file) contains the following two lines:
GITHUB_CLIENT_ID=YOUR_GITHUB_CLIENT_ID
GITHUB_CLIENT_SECRET=YOUR_GITHUB_CLIENT_SECRET
GITHUB_REDIRECT_URI=http://localhost:7130/api/auth/oauth/github/callbackReplace YOUR_GITHUB_CLIENT_ID and YOUR_GITHUB_CLIENT_SECRET with the actual values you obtained in the previous step.
After completing the above steps, your application is ready to use GitHub OAuth for user authentication.