Revision 512

Date:
2015/09/22 11:10:06
Author:
ahitrov
Revision Log:
VK scope

Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/plugins/session/config.proto

     
    73 73
    74 74 REWRITE += VK_APP_ID VK_APP_SECRET VK_REDIRECT_URL VK_USER_POST_URL
    75 75
    76 ### if additional rights needed:
    77 VK_SCOPE =
    78 REWRITE += VK_SCOPE
    76 79
    77 80 ### AUTH::Mailru
    78 81 ######################################
  • utf8/plugins/session/lib/session/AUTH/VKontakte.pm

     
    33 33
    34 34 =cut
    35 35
    36 our %SCOPE = (
    37 'notify' => 1,
    38 'friends' => 2,
    39 'photos' => 4,
    40 'audio' => 8,
    41 'video' => 16,
    42 'docs' => 131072,
    43 'notes' => 2048,
    44 'pages' => 128,
    45 'menu_link' => 256,
    46 'status' => 1024,
    47 'groups' => 262144,
    48 'email' => 4194304,
    49 'notifications' => 524288,
    50 'stats' => 1048576,
    51 'ads' => 32768,
    52 'offline' => 65536,
    53 );
    54
    36 55 sub new {
    37 56 my ($class, %config) = @_;
    38 57 my $self = bless {}, $class;
     
    41 60 $self->{vk_access_token_url} = 'https://oauth.vk.com/access_token';
    42 61 $self->{vk_user_info_url} = 'https://api.vk.com/method/getProfiles';
    43 62
    44 for (qw( vk_app_id vk_app_secret )) {
    63 for (qw( vk_app_id vk_app_secret vk_scope)) {
    45 64 $self->{$_} = $config{$_} || $state->{session}->{$_} || return undef;
    46 65 }
    47 66 $self->{timeout} = $state->{session}->{connection_timeout} || 3;
     
    56 75 my (%args) = @_;
    57 76 my $go = URI->new( $self->{vk_authorize_url} );
    58 77 $go->query_param( client_id => $self->{vk_app_id} );
    59 $go->query_param( scope => '' );
    78 $go->query_param( scope => $self->{vk_scope} || '' );
    60 79 $go->query_param( response_type => 'code' );
    61 80 $args{redirect_uri} ||= $self->{vk_redirect_uri};
    62 81 for ( keys %args ) {
     
    145 164
    146 165 my @plugins = split (/[\ |\t]+/, $state->{plugins});
    147 166 my $name = $user_info->{first_name}.' '.$user_info->{last_name};
    167 my $email = exists $user_info->{email} && $user_info->{email} ? $user_info->{email} : undef;
    148 168 if ( grep { $_ eq 'users' } @plugins ) {
    149 169 my $user;
    150 170 if ( $state->{users}->use_credentials ) {
     
    170 190 if ( exists $props{country} ) {
    171 191 $user->country( $user_info->{country} );
    172 192 }
    173 $user->email( undef );
    193 $user->email( $email );
    174 194
    175 195 my ($prop_ava) = grep { $_->{attr} eq 'avatar' && $_->{type} eq 'image' } $user->structure;
    176 196 if ( ref $prop_ava ) {
     
    217 237 if ( $user_info->{photo} ) {
    218 238 $data{avatar} = $user_info->{photo};
    219 239 }
    240 if ( $user_info->{email} ) {
    241 $data{email} = $user_info->{email};
    242 }
    220 243 $local_session->set( %data );
    221 244 }
    222 245 return $local_session;
  • utf8/plugins/session/lib/session/State.pm.proto

     
    72 72 $self->{vk_app_secret} = '@VK_APP_SECRET@';
    73 73 $self->{vk_redirect_uri} = '@VK_REDIRECT_URL@';
    74 74 $self->{vk_user_post_url} = '@VK_USER_POST_URL@';
    75 $self->{vk_scope} = '@VK_SCOPE@';
    75 76
    76 77 $self->{mailru_app_id} = '@MAILRU_APP_ID@';
    77 78 $self->{mailru_app_secret} = '@MAILRU_APP_SECRET@';