Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Update for latest gem updates #3

Merged
merged 3 commits into from almost 2 years ago

2 participants

Marc Cooper Charlie Park
Marc Cooper
auxbuss commented

Basically, this replaces oa-oauth with the latest omniauth and omniauth-twitter gems. I've also updated the README to reflect these changes, and also presented a fix for the shotgun/reloader issues mentioned.

Charlie Park
Owner

Marc, thank you for these updates.

Charlie Park charliepark merged commit bb33cbf into from
Charlie Park charliepark closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
1  .gitignore
... ...
@@ -0,0 +1 @@
  1
+database.db
34  README.md
Source Rendered
... ...
@@ -1,38 +1,48 @@
1 1
 # Omniauth for Sinatra
2 2
 
3  
-This is a template for launching Sinatra apps quickly and easily, using [OmniAuth](https://github.com/intridea/omniauth) as the authentication protocol. It differs from most of the "use Twitter with Sinatra" code bases, as it incorporates sessions and a User model in the database. This means your user should remain logged in as long as your server stays live.
  3
+This is a template for launching Sinatra apps quickly and easily,
  4
+using [OmniAuth](https://github.com/intridea/omniauth) as the authentication protocol.
  5
+It differs from most of the "use Twitter with Sinatra" code bases, as it incorporates
  6
+sessions and a `User` model in the database. This means your user should remain logged
  7
+in as long as your server stays live.
4 8
 
5 9
 The instructions here assume you're using Twitter, but you can use any auth provider handled by OmniAuth.
6 10
 
7  
-Most of the actual code here is simply a port/mashup of Ryan Bates's example from [RailsCasts #241: Simple OmniAuth](http://railscasts.com/episodes/241-simple-omniauth) and the OmniAuth readme.
8  
-
9  
-Once you have your auth codes, getting a new Sinatra app with authentication working is simply a matter of copying the app.rb file from here into a new directory, pasting in your auth codes, and then starting in on your app's code. It just works.
  11
+Most of the actual code here is simply a port/mashup of Ryan Bates's example from [RailsCasts #241:
  12
+Simple OmniAuth](http://railscasts.com/episodes/241-simple-omniauth) and the OmniAuth readme.
10 13
 
  14
+Once you have your auth codes, getting a new Sinatra app with authentication working is simply a matter
  15
+of copying the `app.rb` file from here into a new directory, pasting in your auth codes, and then starting
  16
+in on your app's code. It just works.
11 17
 
12 18
 ## Getting Started Instructions
13 19
 
14 20
 ### 1. Install Omniauth and the other required gems
15 21
 
16  
-    gem install omniauth
17  
-
18  
-You'll also need to install data_mapper and dm-sqlite-adapter if you don't have them in your system.
19  
-
  22
+    gem install omniauth omniauth-twitter dm-core dm-sqlite-adapter dm-migrations sinatra
20 23
 
21 24
 ### 2. Get your Twitter Auth Keys
22 25
 
23  
-At Twitter, [register for a new app](https://dev.twitter.com/apps/new). Note the Consumer Key and Consumer Secret strings it gives you.
  26
+At Twitter, [register for a new app](https://dev.twitter.com/apps/new).
  27
+Note the _Consumer Key_ and _Consumer Secret_ strings it gives you.
24 28
 
25 29
 
26 30
 ### 3. Enter your Auth Keys into the app.rb file
27 31
 
28  
-The file app.rb has a place for your CONSUMER_KEY and CONSUMER_SECRET. Just replace them, and you're set. Fire up your local server ('ruby app.rb') and you can see your log-in setup.
  32
+The file `app.rb` has a place for your `CONSUMER_KEY` and `CONSUMER_SECRET`. Just replace them, and you're
  33
+set. Fire up your local server via `ruby app.rb` and you can see your log-in setup.
29 34
 
30 35
 
31 36
 ## A Minor Note
32 37
 
33  
-Note that **you cannot use shotgun to test your app**, as you'll need sessions to persist in order to stay logged in, and shotgun restarts the server on every request. Starting your app with 'ruby app.rb' should work with no problems.
  38
+Note that if you want to use shotgun or reloader while testing your app, then you'll need to set
  39
+`:session_secret` in your configure block:
34 40
 
  41
+    configure :development, :testing do
  42
+      set :session_secret, "random string"
  43
+    end
35 44
 
36 45
 ## Feedback Is Awesome
37 46
 
38  
-I'd really love to hear any suggestions you have on how to improve this. On Twitter, I'm [@charliepark](https://twitter.com/charliepark/). By e-mail, I'm charlie@monotask.com.
  47
+I'd really love to hear any suggestions you have on how to improve this. On Twitter,
  48
+I'm [@charliepark](https://twitter.com/charliepark/). By e-mail, I'm charlie@monotask.com.
4  app.rb
... ...
@@ -1,4 +1,4 @@
1  
-%w(rubygems oa-oauth dm-core dm-sqlite-adapter dm-migrations sinatra).each { |dependency| require dependency }
  1
+%w(omniauth omniauth-twitter dm-core dm-sqlite-adapter dm-migrations sinatra).each { |dependency| require dependency }
2 2
 
3 3
 DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/database.db")
4 4
 
@@ -67,4 +67,4 @@ def current_user
67 67
     session[:user_id] = nil
68 68
     redirect '/'
69 69
   end
70  
-end
  70
+end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.