Our great sponsors
-
Puts Debuggerer
Ruby library for improved puts debugging, automatically displaying bonus useful information such as source line number and source code.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
But what if we've already gone through this process on another site? Wouldn't it be nice if we could somehow communicate with that site's authentication system and use it to authenticate the users on our site? This is precisely what OmniAuth allows us to do, specifically through the use of community-built strategies, or code that allows one to authenticate to a given provider, e.g. Facebook or GitHub. You know those "Login with Facebook" buttons? Yep, that's what we're talking about here.
To authenticate to GitHub, we must tell GitHub who we are and that we will be requesting information from its API. To do this, we must register our application as a new OAuth app. Navigate to GitHub. Login and under your profile picture, click on Settings. Scroll down a bit and click on Developer Settings. Click on OAuth Apps, and finally "New OAuth App".
In this post, I will go over the steps I took to authenticate to GitHub in a Rails development environment using the omniauth-github gem, "the official OmniAuth strategy for authenticating to GitHub", along with Devise, the figaro gem, and ngrok, a nifty tool that exposes your local WebHost to the internet. This guide will assume you already have Devise authentication setup for your app. See the link above for installation instructions.
In this post, I will go over the steps I took to authenticate to GitHub in a Rails development environment using the omniauth-github gem, "the official OmniAuth strategy for authenticating to GitHub", along with Devise, the figaro gem, and ngrok, a nifty tool that exposes your local WebHost to the internet. This guide will assume you already have Devise authentication setup for your app. See the link above for installation instructions.
In this post, I will go over the steps I took to authenticate to GitHub in a Rails development environment using the omniauth-github gem, "the official OmniAuth strategy for authenticating to GitHub", along with Devise, the figaro gem, and ngrok, a nifty tool that exposes your local WebHost to the internet. This guide will assume you already have Devise authentication setup for your app. See the link above for installation instructions.
Registering a new OAuth app with GitHub to use the GitHub API.
Related posts
- Declaring multiple sets of scopes for the same provider with Devise and OmniAuth in Rails
- Ruby on Rails: Native route constraint for authentication
- What is the best way to implement social logins in an API-only Rails app?
- Using Action Policy for a Ruby on Rails App: The Basics
- Generate a pre-built authentication system into a rails application