Sha256: 07bb09e4b533170e2062ebd61be55c66a1fb04dc1e01c2a3826aa1f8a8d47d57
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
module OmniAuth module Strategies class OAuth include OmniAuth::Strategy def initialize(app, name, consumer_key, consumer_secret, options = {}) require 'oauth' super @consumer = ::OAuth::Consumer.new(consumer_key, consumer_secret, options) end attr_reader :name, :consumer def request_phase request_token = consumer.get_request_token(:oauth_callback => callback_url) (session[:oauth]||={})[name.to_sym] = {:callback_confirmed => request_token.callback_confirmed?, :request_token => request_token.token, :request_secret => request_token.secret} r = Rack::Response.new r.redirect request_token.authorize_url r.finish end def callback_phase request_token = ::OAuth::RequestToken.new(consumer, session[:oauth][name.to_sym].delete(:request_token), session[:oauth][name.to_sym].delete(:request_secret)) @access_token = request_token.get_access_token(:oauth_verifier => request.params['oauth_verifier']) request['auth'] = self.auth_hash @app.call(self.env) rescue ::OAuth::Unauthorized fail!(:invalid_credentials) end def auth_hash OmniAuth::Utils.deep_merge(super, { 'credentials' => { 'token' => @access_token.token, 'secret' => @access_token.secret }, 'extra' => { 'access_token' => @access_token } }) end def unique_id nil end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
oa-oauth-0.0.1 | lib/omniauth/strategies/oauth.rb |