Thank you for reading this post, don't forget to share!
How to Implement “Login with GitHub” in a React App
Github Login: A centralized web-based solution for repositories is called GitHub. Millions of individuals used it to work on countless projects.
Even though it isn’t a direct component of the Git project, it’s unlikely that anyone could avoid it. With a GitHub Account, it’s possible to perform a wide range of tasks on the platform in addition to hosting the repositories, including code review and issue tracking.
The first step in contributing to a world where so many collaborations take place every day is discussed in this chapter. Throughout this lesson, we will learn about setting up an account and logging in to GitHub.
Setting Up GitHub Account
Setting up a GitHub account is incredibly quick and easy. Visit the GitHub’s official website to create the account.
On the same page, a login form will be shown. To register for a GitHub account, fill out the form with your information.
Reminder: GitHub will alert you if there are duplicate entries, such as whether or not another person already claims the username.
GitHub will also recommend the available attributes in addition to the problem. For instance, your username can be the same since the choice you made for it might already be in use by someone person.
You will be identified on GitHub by your username. It must therefore be special. GitHub flags the issue and offers several other suggestions.
Fill out the form with your information to avoid making duplicate entries. The green checkmark will represent genuine and accurate entries.
When you click the Sign up for GitHub button, a message asking you to confirm that you are not a robot will appear.
Access your GitHub account
- Go to github.com.
- Click on Sign In at the top right to log in.
Create a GitHub Oauth App
Go to the GitHub Developer Settings page:
- Click on your profile photo at the top right
- Click Settings near the bottom of the menu
- In the left sidebar, click Developer settings (near the bottom)
- In the left sidebar, click OAuth Apps
Enter your GitHub credentials into your Supabase Project
- Go to your Supabase Project Dashboard
- In the left sidebar, click the Authentication icon (near the top)
- Click on Providers under the Configuration section
- Click on GitHub from the accordion list to expand and turn GitHub Enabled to ON
- Enter your GitHub Client ID and GitHub Client Secret saved in the previous step
- Click Save
We must first obtain our GitHub credentials for our Github login to function. Fill out the Application Name, Homepage URL, and Authorization callback URL fields on this link to register your OAuth application.
For the moment, you can use http://localhost:3000 for both URLs. To register an application, click it.
Grab your Client ID, select Generate a new client secret, and copy your new client secret on the following screen. To connect to Github, we’ll utilize both of these keys.
Go to server/main.js and import the ServiceConfiguration to add your GitHub credentials. Next, set up your server to connect completely to Github.
Choosing a GitHub Account Plan
After confirming your identification, you may select the GitHub plan you want to subscribe to.
The GitHub Free plan is more than adequate for this course and beginners.
GitHub Pro is available for individuals who want additional private repositories and a large number of contributors to these repositories.
These are often businesses. If you pick GitHub Pro, you can get more sophisticated tools like secured branches or graphs that show data about your repositories like contributors, traffic, commits, etc. You may learn more about the GitHub Pro plan by clicking on this link.
GitHub asks you questions as you establish your account to “tailor” your experience. It will be the following action in the procedure.
Note: This survey window may or may not appear for you.
This survey aims to gather information on users and the factors that influenced their choice to open a GitHub account. There are three questions in it. If you’d prefer to skip this step, you can.
You will then be required to confirm your email address in the following step. You can confirm by clicking the link GitHub supplied you with in your email.
GitHub Account Dashboard
Once the GitHub account has been created, you can log in using your login information on the GitHub website. After logging in, you will be sent to the GitHub dashboard, customized for each user based on their interests.
Three sections will be present in a GitHub dashboard.
Noting this will complicate matters because the header section contains crucial ideas. At this time, kindly ignore the section.
- GitHub Repositories
- GitHub Feed
- GitHub Discover Repositories
Although briefly described in the section below, these topics will be covered in more detail in the next tutorials.
All the repositories the user is working on are listed in the GitHub repositories section. One can quickly switch between these repositories and begin working on them.
Like other social networks, GitHub feeds include a person’s feed. You may view both your repositories’ most recent activity and the activity of the people you follow.
All activity from both private and public repositories will be included in this feed. Private repositories may include those the company maintains, or the user has personally developed.
GitHub Discover Repositories
GitHub has just added this component to the dashboard. A person can view some repositories that fit his interests in this section. You can always browse the repositories through this section if you aren’t working on any particular repository and improve your GitHub reputation.
This should be sufficient for you to begin using GitHub. It is the initial stage, so don’t worry if you don’t comprehend the user interface or how items are listed on the website. We will go into great detail about these topics in the upcoming tutorials.
Now that you have signed up on the website and joined the largest community (in terms of computer science) attempt to investigate GitHub a little bit on your own. See some bugs that others have raised with your favorite program while exploring some fantastic repositories.
Push a branch to GitHub
The commit on your branch will now be pushed to your brand-new GitHub repository. This makes it possible for others to observe the modifications you’ve made. The changes can be merged into the main branch if the repository’s owner accepts them.
Run git push origin your branch name to upload changes to a new branch on GitHub. On the remote repository, GitHub will immediately create the branch for you:
mnelson:myproject mnelson$ git push origin my-new-branch Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 313 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/cubeton/mynewrepository.git * [new branch] my-new-branch -> my-new-branch
view rawaddnewbranchgithub.md hosted with by GitHub
You might wonder what the command above implies when it uses the word “origin.” Git provides an alias for you when you clone a remote repository to your local computer.
This pseudonym is almost always referred to as “origin.” It serves as a shortcut for the URL of the remote repository.
Therefore, you could have used either the command: git push [email protected]:git/git.git your branch name or git push origin your branch name to push your changes to the remote repository.
(If you are using GitHub locally for the first time, you might be prompted to check in with your GitHub username and password.)
A notice stating that a branch bearing your name has recently been published into the repository can be seen if you reload the GitHub page. You may also view a list of all the branches by clicking the ‘branches’ link.
Now press the green button seen in the preceding screenshot. There will be a pull request from us!
You will be able to smoothly incorporate the “Login with GitHub” functionality into your app if you follow the few steps outlined above.
Q.1 How to create an GitHub account?
- Enter a password, user name, and email address.
- Select Sign up for GitHub, then adhere to the directions.
Q.2 Why is GitHub not letting me create an account?
Q.3 Is creating GitHub account free?
ANS. Organizations can be used for free using GitHub Free, which has a few restrictions on private repositories.
Q.4 How do I create a GitHub email?
- In the “Access” section of the sidebar, click Emails.
- In “Add email address”, type your email address and click Add.
- Verify your email address.
Q.5 Why do I need a GitHub account?
ANS. You may import or create repositories, interact with others, and engage with the GitHub community with a personal account. This tutorial will lead you to create a GitHub account and utilize the platform’s community and collaboration tools.