Class: OmniAuth::Strategies::Pixiv

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

Constant Summary collapse

RAW_INFO_URL =
'/v1/me?include_email=1&include_profile=1&get_secure_url=1&profile_image_sizes=px_16x16,px_50x50,px_170x170'.freeze

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



49
50
51
52
53
54
55
# File 'lib/omniauth/strategies/pixiv.rb', line 49

def authorize_params
  super.tap do |params|
    # Pass through request_type as part of oauth state parameter.
    state_with_request_type = "security_token=#{params[:state]},request_type=#{request.params['request_type'] || 'default'}"
    session['omniauth.state'] = params[:state] = request.params['state'] = state_with_request_type
  end
end

#callback_urlObject



41
42
43
# File 'lib/omniauth/strategies/pixiv.rb', line 41

def callback_url
  full_host + script_name + callback_path
end

#clientObject



33
34
35
36
37
38
39
# File 'lib/omniauth/strategies/pixiv.rb', line 33

def client
  ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(options.client_options)) do |faraday|
    faraday.request :url_encoded
    faraday.request :user_agent, options[:user_agent]
    faraday.adapter Faraday.default_adapter
  end
end

#raw_infoObject



45
46
47
# File 'lib/omniauth/strategies/pixiv.rb', line 45

def raw_info
  @raw_info ||= access_token.get(RAW_INFO_URL).parsed['response'].first
end