When a user authenticates via GitHub, GitHub will provide you with a set of user information, including their GitHub username, GitHub ID, email (if accessible), and other details.
You should create a new user record in your database (or update an existing one) with this information.
At a minimum, store the following:
GitHub ID: A unique identifier for the user across all of GitHub.
Username: The user's GitHub username.
Email: The user's email address (if accessible).
OAuth Token: The OAuth token provided by GitHub for making authenticated API requests on behalf of the user.
User Lookup:
When a user logs in via GitHub in the future, use their GitHub ID to look up their existing record in your database.
If the user exists, log them in; if not, create a new record.
Handling Additional Information:
If your application requires more information than what GitHub provides, you might prompt the user to enter those details after their initial login.
For example, you might ask for a preferred workspace or additional settings specific to your application.
Authorization and Roles:
Depending on your application’s needs, you might also want to assign roles or permissions to users. This can be stored alongside the user record in your database.
GitHub ID
: A unique identifier for the user across all of GitHub.Username
: The user's GitHub username.Email
: The user's email address (if accessible).OAuth Token
: The OAuth token provided by GitHub for making authenticated API requests on behalf of the user.