module Sorcery::Protocols::Oauth2

Public Instance Methods

authorize_url(options = {}) click to toggle source
# File lib/sorcery/protocols/oauth2.rb, line 10
def authorize_url(options = {})
  client = build_client(options)
  client.auth_code.authorize_url(
    redirect_uri: @callback_url,
    scope: @scope,
    display: @display,
    state: @state
  )
end
build_client(options = {}) click to toggle source
# File lib/sorcery/protocols/oauth2.rb, line 32
def build_client(options = {})
  defaults = {
    site: @site,
    ssl: { ca_file: Sorcery::Controller::Config.ca_file }
  }
  ::OAuth2::Client.new(
    @key,
    @secret,
    defaults.merge!(options)
  )
end
get_access_token(args, options = {}) click to toggle source
# File lib/sorcery/protocols/oauth2.rb, line 20
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_version() click to toggle source
# File lib/sorcery/protocols/oauth2.rb, line 6
def oauth_version
  '2.0'
end