class OmniAuth::Strategies::Zooniverse

Constants

BASE_SCOPES
DEFAULT_SCOPE

Public Instance Methods

authorize_params() click to toggle source
Calls superclass method
# File lib/omniauth/strategies/zooniverse.rb, line 23
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

    raw_scope = params[:scope] || DEFAULT_SCOPE
    scope_list = raw_scope.split(" ").map {|item| item.split(",")}.flatten
    scope_list.map! { |s| s =~ /^https?:\/\// || BASE_SCOPES.include?(s) ? s : "#{BASE_SCOPE_URL}#{s}" }
    params[:scope] = scope_list.join(" ")
  end
end
raw_info() click to toggle source
# File lib/omniauth/strategies/zooniverse.rb, line 45
def raw_info
  return @raw_info if @raw_info
  token_response = access_token.get(
    '/api/me',
    headers: {'Accept' => "application/vnd.api+json; version=1"}
  )
  raw = JSON.parse(token_response.body)
  @raw_info = raw["users"][0]
end