Adding Github OAuth to Rails Project Part I

Perezchristian
1 min readJan 5, 2021

--

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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Perezchristian
Perezchristian

Written by Perezchristian

Flatiron School Graduate with finance, budget, and tax experience.

No responses yet

Write a response