Module: Sorcery::Controller::Submodules::External::Protocols::Oauth2
- Included in:
- Sorcery::Controller::Submodules::External::Providers::Facebook::FacebookClient, Sorcery::Controller::Submodules::External::Providers::Github::GithubClient, Sorcery::Controller::Submodules::External::Providers::Google::GoogleClient, Sorcery::Controller::Submodules::External::Providers::Liveid::LiveidClient, Sorcery::Controller::Submodules::External::Providers::Vk::VkClient
- Defined in:
- lib/sorcery/controller/submodules/external/protocols/oauth2.rb
Instance Method Summary collapse
- #authorize_url(options = {}) ⇒ Object
- #build_client(options = {}) ⇒ Object
- #get_access_token(args, options = {}) ⇒ Object
- #oauth_version ⇒ Object
Instance Method Details
#authorize_url(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/sorcery/controller/submodules/external/protocols/oauth2.rb', line 12 def ( = {}) client = build_client() client.auth_code.( :redirect_uri => @callback_url, :scope => @scope, :display => @display, :state => @state ) end |
#build_client(options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sorcery/controller/submodules/external/protocols/oauth2.rb', line 34 def build_client( = {}) defaults = { :site => @site, :ssl => { :ca_file => Config.ca_file } } ::OAuth2::Client.new( @key, @secret, defaults.merge!() ) end |
#get_access_token(args, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sorcery/controller/submodules/external/protocols/oauth2.rb', line 22 def get_access_token(args, = {}) client = build_client() client.auth_code.get_token( args[:code], { :redirect_uri => @callback_url, :parse => .delete(:parse) }, ) end |
#oauth_version ⇒ Object
8 9 10 |
# File 'lib/sorcery/controller/submodules/external/protocols/oauth2.rb', line 8 def oauth_version "2.0" end |