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: vk.com/dev/authentication

Examples:

Basic Usage

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

Defined Under Namespace

Classes: NoRawData

Constant Summary collapse

API_VERSION =
'5.107'
DEFAULT_SCOPE =
''

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject

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

vk.com/dev/oauth_dialog

revoke revokes access and re-authorizes user.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/omniauth/strategies/vkontakte.rb', line 77

def authorize_params
  super.tap do |params|
    # just a copypaste from ominauth-facebook
    %w[display state scope revoke].each do |v|
      next unless 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

    params[:scope] ||= DEFAULT_SCOPE
  end
end

#raw_infoObject



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/omniauth/strategies/vkontakte.rb', line 59

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