lib/omniauth/strategies/oauth2.rb in oa-oauth-0.0.1 vs lib/omniauth/strategies/oauth2.rb in oa-oauth-0.0.4

- old
+ new

@@ -1,7 +1,9 @@ require 'cgi' require 'uri' +require 'oauth2' +require 'omniauth/oauth' module OmniAuth module Strategies class OAuth2 include OmniAuth::Strategy @@ -10,19 +12,21 @@ super(app, name) @options = options @client = ::OAuth2::Client.new(client_id, client_secret, options) end - attr_accessor :client_id, :client_secret, :options + protected + attr_accessor :client + def request_phase(options = {}) - redirect @client.web_server.authorize_url({:redirect_uri => callback_url}.merge(options)) + redirect client.web_server.authorize_url({:redirect_uri => callback_url}.merge(options)) end def callback_phase verifier = request.params['code'] - @access_token = @client.web_server.get_access_token(verifier, :redirect_uri => callback_url) + @access_token = client.web_server.get_access_token(verifier, :redirect_uri => callback_url) super rescue ::OAuth2::HTTPError => e fail!(:invalid_credentials) end @@ -33,6 +37,6 @@ } }) end end end -end \ No newline at end of file +end