Revision 676
- Date:
- 2018/03/27 08:39:47
- Files:
Legend:
- Added
- Removed
- Modified
-
utf8/plugins/session/lib/session/AUTH/VKontakte.pm
3 3 use strict; 4 4 use warnings; 5 5 use LWP::UserAgent; 6 use IO::Socket::SSL; 6 7 use JSON::XS; 7 8 use Data::Dumper; 8 9 use URI; … … 18 19 auto_create_user: 1 19 20 app_id: decimal digits 20 21 app_secret: 32 hex digits 21 authorize_url: http://api.vkontakte.ru/oauth/authorize 22 access_token_url: https://api.vkontakte.ru/oauth/access_token 23 user_info_url: https://api.vkontakte.ru/method/account.getProfileInfo 22 authorize_url: http://oauth.vk.com/authorize 23 access_token_url: https://oauth.vk.com/access_token 24 user_info_url: https://api.vk.com/method/account.getProfileInfo 24 25 user_post_url: ~ 25 26 =cut 26 27 … … 63 64 for (qw( vk_app_id vk_app_secret )) { 64 65 $self->{$_} = $config{$_} || $state->{session}->{$_} || return undef; 65 66 } 66 $self->{vk_scope} = $config{$_} || $state->{session}->{$_}; 67 if ( $config{vk_scope} || $state->{session}->{vk_scope} ) { 68 $self->{vk_scope} = $config{vk_scope} || $state->{session}->{vk_scope}; 69 } 67 70 $self->{timeout} = $state->{session}->{connection_timeout} || 3; 68 71 for (qw(vk_user_post_url vk_redirect_uri)) { 69 72 $self->{$_} = $config{$_} || $state->{session}->{$_}; 70 73 } 74 $self->{vk_api_version} = '5.52'; 71 75 return $self; 72 76 } 73 77 … … 79 83 $go->query_param( scope => $self->{vk_scope} || '' ); 80 84 $go->query_param( display => 'page' ); 81 85 $go->query_param( response_type => 'code' ); 82 $go->query_param( v => '5.44' ); 86 $go->query_param( v => $self->{vk_api_version} ); 83 87 $args{redirect_uri} ||= $self->{vk_redirect_uri}; 84 88 for ( keys %args ) { 85 89 $go->query_param( $_ => $args{$_} ); … … 119 123 $req->query_param( client_secret => $self->{vk_app_secret} ); 120 124 $req->query_param( code => $code ); 121 125 $req->query_param( redirect_uri => $redirect_uri ); 126 $req->query_param( v => $self->{vk_api_version} ); 122 127 warn "Token request: [$req]\n" if $DEBUG; 123 128 my $res = $ua->get($req); 124 129 unless ($res->code == 200) { … … 152 157 $req->query_param( uid => $local_session->{vk_user_id} ); 153 158 $req->query_param( fields => join ',', @fields ); 154 159 $req->query_param( access_token => $access_token ); 160 $req->query_param( v => $self->{vk_api_version} ); 155 161 156 162 warn "VK: Fetching user $req\n" if $DEBUG; 157 163 my $res = $ua->get($req);