Browse files

initial checkin

  • Loading branch information...
0 parents commit e93dd58b6f975a5085d7b3f60800b7b31c78a46d @chrismatthieu committed Jun 30, 2011
Showing with 44 additions and 0 deletions.
  1. +2 −0 Gemfile
  2. +2 −0 config.ru
  3. +40 −0 githubchat.rb
2 Gemfile
@@ -0,0 +1,2 @@
+gem 'sinatra'
+gem 'omniauth'
2 config.ru
@@ -0,0 +1,2 @@
+require 'githubchat'
+run Sinatra::Application
40 githubchat.rb
@@ -0,0 +1,40 @@
+begin
+ require 'sinatra'
+ require 'omniauth'
+rescue LoadError
+ require 'rubygems'
+ require 'sinatra'
+ require 'omniauth'
+end
+
+use Rack::Session::Cookie
+use OmniAuth::Builder do
+ provider :github, '74a1475d7f5564343099', 'f8310520720f56e931f086d519c435d800c6997a'
+end
+
+get '/' do
+ <<-HTML
+ <a href='/auth/github'>Sign in with GitHub</a>
+ HTML
+end
+
+post '/auth/:name/callback' do
+ omniauth = request.env['omniauth.auth']
+ # do whatever you want with the information!
+end
+
+get '/auth/:name/callback' do
+ omniauth = request.env['omniauth.auth']
+
+ # create a new hash
+ @authhash = Hash.new
+
+ omniauth['user_info']['email'] ? @authhash[:email] = omniauth['user_info']['email'] : @authhash[:email] = ''
+ omniauth['user_info']['name'] ? @authhash[:name] = omniauth['user_info']['name'] : @authhash[:name] = ''
+ omniauth['extra']['user_hash']['id'] ? @authhash[:uid] = omniauth['extra']['user_hash']['id'].to_s : @authhash[:uid] = ''
+ omniauth['provider'] ? @authhash[:provider] = omniauth['provider'] : @authhash[:provider] = ''
+
+ # session[:user] = @authhash
+
+end
+

0 comments on commit e93dd58

Please sign in to comment.