-
-
Notifications
You must be signed in to change notification settings - Fork 981
Sinatra Example
Marco Antonio edited this page Sep 29, 2018
·
12 revisions
begin
require 'sinatra'
require 'omniauth'
require 'openid/store/filesystem'
require 'omniauth-twitter'
rescue LoadError
require 'rubygems'
require 'sinatra'
require 'omniauth'
require 'openid/store/filesystem'
require 'omniauth-twitter'
end
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :open_id, OpenID::Store::Filesystem.new('/tmp')
provider :twitter, 'consumerkey', 'consumersecret'
end
get '/' do
<<-HTML
<a href='/auth/twitter'>Sign in with Twitter</a>
<form action='/auth/open_id' method='post'>
<input type='text' name='identifier'/>
<input type='submit' value='Sign in with OpenID'/>
</form>
HTML
end
post '/auth/:name/callback' do
auth = request.env['omniauth.auth']
# do whatever you want with the information!
end
User Docs
- List of Strategies
- Frequently Asked Questions
- Help Topics
- External Resources
- Upgrading to 1.0
- Upgrading to 2.0
- Auth Hash Schema
Strategy Developers
Project Resources