Module: Sorcery::Controller::Submodules::External::Protocols::Oauth2

Instance Method Summary collapse

Instance Method Details

#authorize_url(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/sorcery/controller/submodules/external/protocols/oauth2.rb', line 12

def authorize_url(options = {})
  client = build_client(options)
  client.auth_code.authorize_url(
    :redirect_uri => @callback_url,
    :scope => @scope,
    :display => @display
  )
end

#build_client(options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sorcery/controller/submodules/external/protocols/oauth2.rb', line 29

def build_client(options = {})
  defaults = {
    :site => @site,
    :ssl => { :ca_file => Config.ca_file }
  }
  ::OAuth2::Client.new(
    @key,
    @secret,
    defaults.merge!(options)
  )
end

#get_access_token(args, options = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/sorcery/controller/submodules/external/protocols/oauth2.rb', line 21

def get_access_token(args, options = {})
  client = build_client(options)
  client.auth_code.get_token(
    args[:code],
    { :redirect_uri => @callback_url, :parse => options.delete(:parse) }, options
  )
end

#oauth_versionObject



8
9
10
# File 'lib/sorcery/controller/submodules/external/protocols/oauth2.rb', line 8

def oauth_version
  "2.0"
end