@@ -7,12 +7,15 @@ var Parse = require('parse/node').Parse;
77
88// Returns a promise that fulfills iff this user id is valid.
99function validateAuthData ( authData , params ) {
10- return vkOAuth2Request ( params ) . then ( function ( response ) {
10+ return vkOAuth2Request ( params ) . then ( function ( response ) {
1111 if ( response && response . access_token ) {
1212 return request (
1313 'api.vk.com' ,
14- 'method/users.get?access_token=' + authData . access_token + '&v=5.8'
15- ) . then ( function ( response ) {
14+ 'method/users.get?access_token=' +
15+ authData . access_token +
16+ '&v=' +
17+ params . apiVersion
18+ ) . then ( function ( response ) {
1619 if (
1720 response &&
1821 response . response &&
@@ -35,7 +38,7 @@ function validateAuthData(authData, params) {
3538}
3639
3740function vkOAuth2Request ( params ) {
38- return new Promise ( function ( resolve ) {
41+ return new Promise ( function ( resolve ) {
3942 if (
4043 ! params ||
4144 ! params . appIds ||
@@ -48,15 +51,20 @@ function vkOAuth2Request(params) {
4851 'Vk auth is not configured. Missing appIds or appSecret.'
4952 ) ;
5053 }
54+ if ( ! params . apiVersion ) {
55+ params . apiVersion = '5.124' ;
56+ }
5157 resolve ( ) ;
52- } ) . then ( function ( ) {
58+ } ) . then ( function ( ) {
5359 return request (
5460 'oauth.vk.com' ,
5561 'access_token?client_id=' +
5662 params . appIds +
5763 '&client_secret=' +
5864 params . appSecret +
59- '&v=5.59&grant_type=client_credentials'
65+ '&v=' +
66+ params . apiVersion +
67+ '&grant_type=client_credentials'
6068 ) ;
6169 } ) ;
6270}
0 commit comments