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
20
21
22
23
24
25
26
# File 'lib/sorcery/controller/submodules/external/protocols/oauth2.rb', line 12

def authorize_url(options = {})
  defaults = {
    :site => @site,
    :ssl => { :ca_file => Config.ca_file }
  }
  client = ::OAuth2::Client.new(
    @key,
    @secret,
    defaults.merge!(options)
  )
  client.web_server.authorize_url(
    :redirect_uri => @callback_url,
    :scope => @scope
  )
end

#get_access_token(args) ⇒ Object



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

def get_access_token(args)
  client = ::OAuth2::Client.new(
    @key,
    @secret,
    :site => @site,
    :ssl => { :ca_file => Config.ca_file }
  )
  client.web_server.get_access_token(
    args[:code],
    :redirect_uri => @callback_url
  )
end

#oauth_versionObject



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

def oauth_version
  "2.0"
end