Class: OmniAuth::Strategies::AlliedModders

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

Constant Summary collapse

DEFAULT_SCOPE =

Possible scopes: userinfo.email,userinfo.profile,plus.me

""

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/omniauth/strategies/allied_modders.rb', line 19

def authorize_params
  base_scope_url = ""
  super.tap do |params|
    # Read the params if passed directly to omniauth_authorize_path
    %w(scope approval_prompt access_type state hd).each do |k|
      params[k.to_sym] = request.params[k] unless [nil, ''].include?(request.params[k])
    end
    scopes = (params[:scope] || DEFAULT_SCOPE).split(",")
    scopes.map! { |s| s =~ /^https?:\/\// ? s : "#{base_scope_url}#{s}" }
    params[:scope] = scopes.join(' ')
    # This makes sure we get a refresh_token.
    # http://googlecode.blogspot.com/2011/10/upcoming-changes-to-oauth-20-endpoint.html
    params[:access_type] = 'offline' if params[:access_type].nil?
    params[:approval_prompt] = 'force' if params[:approval_prompt].nil?
    # Override the state per request
    session['omniauth.state'] = params[:state] if request.params['state']
  end
end

#raw_infoObject



58
59
60
# File 'lib/omniauth/strategies/allied_modders.rb', line 58

def raw_info
  @raw_info ||= access_token.get('https://forums.alliedmods.net/oauth/userinfo.php').parsed
end