class OmniAuth::Strategies::Patreon

Constants

DEFAULT_SCOPE

OAuth client settings

Public Instance Methods

authorize_params() click to toggle source
Calls superclass method
# File lib/j1_app/omniauth/strategies/patreon.rb, line 75
def authorize_params
  super.tap do |params|
    options[:authorize_options].each do |k|
      params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
    end
    params[:scope] = get_scope(params)
    session['omniauth.state'] = params[:state] if params[:state]
  end
end
callback_url() click to toggle source
# File lib/j1_app/omniauth/strategies/patreon.rb, line 43
def callback_url
  options[:redirect_uri] || full_host + script_name + callback_path
end
raw_info() click to toggle source
# File lib/j1_app/omniauth/strategies/patreon.rb, line 91
def raw_info
  @raw_info ||= begin
    response = client.request(
        :get, 'https://api.patreon.com/oauth2/api/current_user',
        headers: {
            'Authorization' => "Bearer #{access_token.token}"
        },
        parse: :json
    )
    response.parsed
  end
end

Private Instance Methods

get_scope(params) click to toggle source

Helpers

# File lib/j1_app/omniauth/strategies/patreon.rb, line 110
def get_scope(params)
  raw_scope = params[:scope] == '' ? DEFAULT_SCOPE : params[:scope]
  scope_list = raw_scope.split(' ').map { |item| item.split(',') }.flatten
  scope_list.join(' ')
end
prune!(hash) click to toggle source
# File lib/j1_app/omniauth/strategies/patreon.rb, line 116
def prune!(hash)
  hash.delete_if do |_, value|
    prune!(value) if value.is_a?(Hash)
    value.nil? || (value.respond_to?(:empty?) && value.empty?)
  end
end
skip_extra?() click to toggle source
# File lib/j1_app/omniauth/strategies/patreon.rb, line 123
def skip_extra?
  !!options[:skip_extra]
end