Class: OmniAuth::Strategies::Vkontakte

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

Overview

Authenticate to Vkontakte utilizing OAuth 2.0 and retrieve basic user information. documentation available here: vkontakte.ru/developers.php?o=-17680044&p=Authorization&s=0

Examples:

Basic Usage

use OmniAuth::Strategies::Vkontakte, 'API Key', 'Secret Key'

Constant Summary collapse

DEFAULT_SCOPE =
'notify'

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject

You can pass displayor scope params to the auth request, if you need to set them dynamically.

/auth/vkontakte?display=popup



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/omniauth/strategies/vkontakte.rb', line 63

def authorize_params
  super.tap do |params|
    # just a copypaste from ominauth-facebook
    %w[display state scope].each do |v|
      if request.params[v]
        params[v.to_sym] = request.params[v]
        # to support omniauth-oauth2's auto csrf protection
        session['omniauth.state'] = params[:state] if v == 'state'
      end
    end
    params[:scope] ||= DEFAULT_SCOPE
  end
end

#raw_infoObject



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

def raw_info
  # http://vkontakte.ru/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter
  fields = ['uid', 'first_name', 'last_name', 'nickname', 'sex', 'city', 'country', 'online', 'bdate', 'photo', 'photo_big', 'domain']
  @raw_info ||= access_token.get('/method/getProfiles', :params => { :uid => uid, :fields => fields.join(',') }).parsed["response"].first
end