class OmniAuth::Strategies::Vkontakte
Authenticate to Vkontakte
utilizing OAuth 2.0 and retrieve basic user information. documentation available here: vk.com/dev/authentication
@example Basic Usage
use OmniAuth::Strategies::Vkontakte, 'API Key', 'Secret Key'
Constants
- API_VERSION
- DEFAULT_SCOPE
Public Instance Methods
raw_info()
click to toggle source
# File lib/omniauth/strategies/vkontakte.rb, line 57 def raw_info access_token.options[:mode] = :query access_token.options[:param_name] = :access_token @raw_info ||= begin result = access_token.get('/method/users.get', params: params).parsed['response'] raise NoRawData, result unless result.is_a?(Array) && result.first result.first end end
Private Instance Methods
callback_phase()
click to toggle source
Calls superclass method
# File lib/omniauth/strategies/vkontakte.rb, line 147 def callback_phase super rescue NoRawData => e fail!(:no_raw_data, e) end
callback_url()
click to toggle source
# File lib/omniauth/strategies/vkontakte.rb, line 102 def callback_url options.redirect_url || (full_host + script_name + callback_path) end
https_option()
click to toggle source
# File lib/omniauth/strategies/vkontakte.rb, line 120 def https_option options[:https] || 0 end
image_url()
click to toggle source
# File lib/omniauth/strategies/vkontakte.rb, line 124 def image_url case options[:image_size] when 'mini' raw_info['photo_50'] when 'bigger' raw_info['photo_100'] when 'bigger_x2' raw_info['photo_200'] when 'original' raw_info['photo_200_orig'] when 'original_x2' raw_info['photo_400_orig'] else raw_info['photo_50'] end end
info_options()
click to toggle source
# File lib/omniauth/strategies/vkontakte.rb, line 106 def info_options # http://vk.com/dev/fields fields = %w[ nickname screen_name sex city country online bdate photo_50 photo_100 photo_200 photo_200_orig photo_400_orig ] fields.concat(options[:info_fields].split(',')) if options[:info_fields] fields.join(',') end
lang_option()
click to toggle source
# File lib/omniauth/strategies/vkontakte.rb, line 116 def lang_option options[:lang] || '' end
location()
click to toggle source
# File lib/omniauth/strategies/vkontakte.rb, line 141 def location country = raw_info.fetch('country', {})['title'] city = raw_info.fetch('city', {})['title'] @location ||= [country, city].compact.join(', ') end
params()
click to toggle source
# File lib/omniauth/strategies/vkontakte.rb, line 93 def params { fields: info_options, lang: lang_option, https: https_option, v: API_VERSION } end