Class: OmniAuth::Strategies::Mixer

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/mixer.rb

Constant Summary collapse

BLANK_PARAMS =
[nil, ''].freeze
DEFAULT_SCOPE =
'user:details:self'.freeze
RAW_INFO_URL =
'/api/v1/users/current'.freeze
SOCIAL_KEYS =
%w(facebook discord player twitter youtube).freeze

Instance Method Summary collapse

Instance Method Details

#access_token_optionsObject



44
45
46
47
48
49
# File 'lib/omniauth/strategies/mixer.rb', line 44

def access_token_options
  options.access_token_options.each_with_object({}) do |(key, val), hsh|
    hsh[key.to_sym] = val
    hsh
  end
end

#authorize_paramsObject



51
52
53
54
55
56
57
58
59
# File 'lib/omniauth/strategies/mixer.rb', line 51

def authorize_params
  super.tap do |params|
    options[:authorize_options].each do |key|
      val = request.params[key.to_s]
      params[key] = val unless BLANK_PARAMS.include? val
    end
    params[:scope] ||= DEFAULT_SCOPE
  end
end

#build_access_tokenObject



61
62
63
64
65
# File 'lib/omniauth/strategies/mixer.rb', line 61

def build_access_token
  super.tap do |token|
    token.options.merge! access_token_options
  end
end

#callback_urlObject



67
68
69
70
# File 'lib/omniauth/strategies/mixer.rb', line 67

def callback_url
  return options[:redirect_url] if options.key? :redirect_url
  full_host + script_name + callback_path
end

#raw_infoObject



72
73
74
# File 'lib/omniauth/strategies/mixer.rb', line 72

def raw_info
  @raw_info ||= access_token.get(RAW_INFO_URL).parsed
end

#social_infoObject



76
77
78
79
80
81
82
# File 'lib/omniauth/strategies/mixer.rb', line 76

def social_info
  raw_social = raw_info['social']
  SOCIAL_KEYS.each_with_object({}) do |key, hsh|
    hsh[key.to_sym] = raw_social[key] if raw_social.key? key
    hsh
  end
end

#urls_infoObject



84
85
86
87
88
# File 'lib/omniauth/strategies/mixer.rb', line 84

def urls_info
  {
    Mixer: "http://mixer.com/#{raw_info['channel']['token']}"
  }
end