Andrew Latham
Andrew Latham

Reputation: 6132

Github Authentication API in Rails

I've been frustrated in my efforts to find information about this because a lot of the links posted on StackOverflow and elsewhere to related topics are 404'd. The Github API only says how to do things from the command line, and none of the gems I've found have given this kind of support. I know, however, that it is possible, because I've seen it done before.

How would I go about getting a user's current Github login information? That is, if a user is logged into Github, I want to find that out and use some of their user information in my website. If they are not logged in, I want to connect to Github to log them in.

Is there a gem for this, and if so, what is it and how does it work (if there isn't sufficient documentation)? If there isn't, then how do I go about using the Github API to do this in Ruby?

Upvotes: 3

Views: 2328

Answers (2)

Zabba
Zabba

Reputation: 65467

For authenticating with github, use the excellent omniauth gem with the (offcial) omniauth-github strategy.

You can see what basic information about the user you will get when the user authenticates with github here.

And here is a list of omniauth strategies that people have posted. For a good getting-started example, see the facebook strategy.

Upvotes: 9

Casey Robinson
Casey Robinson

Reputation: 3268

I found this blog post on using the Omniauth-Github gem. Provides a great tutorial top to bottom.

I used it today with no issues. Blog Post: Omniauth-Github Tutorial

Upvotes: 2

Related Questions