If you want to authenticate your user in your app with Github use omniauth-github strategy for that. Here I am describing how you can do that very quickly. OmniAuth provides list of strategies to use many OAuth for your application. Here is the List of Strategies.
Github uses the OAuth2 flow. First of all you have to register your app with Github GitHub Applications Page. Create a new application here and get Client ID and Secret. Here is how can you obtain Client ID and Secret from Github.
Steps to use these in your app.
1
rails new GithubAuthApp
omniauth-github
1
gem "omniauth-github"
1
2
3
4
use OmniAuth::Builder do
provider :github, XXXX, YYYY
end
All done start you server
1
|
|
Just open your app in browser with URL
1
|
|
You will be redirecting to Github for authentication.
After success your app will redirect to your given callback URL with information and token!
At OmniAuth.org you can try out different -2 Strategies.
Useful links :
- OmniAuth.org One page for all you need.
- omniauth-github gem.