Adding Github OAuth to Rails Project Part I
So I decided to want to add another sign in option using oauth, and I went with using Github. For my MatienanceCo web application, I gave the user two options to sign in, the first was by creating a standalone account via the application, and the second was signing in via Gmail. In my research, I find that Devise would be useful since I will be using two or more sign in options for the user to be able to sign up and login. But at the moment, I installed the gem ‘omniauth-github’ . After installing the gem, I then went about creating the following file config/initializers/github.rb. Within this file, similarly to what I did for my Google Oauth, I had to direct my application to use the gem by populating the file with the following:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET']
end
I then had to go on the Github website and complete the necessary Oauth form in order to register my MaintenanceCo application to Github. So far in my implementation, I have a 404 error when I’m trying to login. Stay tuned to part 2!
Resource: https://docs.github.com/en/free-pro-team@latest/developers/apps/creating-an-oauth-app