@@ -7,12 +7,15 @@ var Parse = require('parse/node').Parse;
7
7
8
8
// Returns a promise that fulfills iff this user id is valid.
9
9
function validateAuthData ( authData , params ) {
10
- return vkOAuth2Request ( params ) . then ( function ( response ) {
10
+ return vkOAuth2Request ( params ) . then ( function ( response ) {
11
11
if ( response && response . access_token ) {
12
12
return request (
13
13
'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 ) {
16
19
if (
17
20
response &&
18
21
response . response &&
@@ -35,7 +38,7 @@ function validateAuthData(authData, params) {
35
38
}
36
39
37
40
function vkOAuth2Request ( params ) {
38
- return new Promise ( function ( resolve ) {
41
+ return new Promise ( function ( resolve ) {
39
42
if (
40
43
! params ||
41
44
! params . appIds ||
@@ -48,15 +51,20 @@ function vkOAuth2Request(params) {
48
51
'Vk auth is not configured. Missing appIds or appSecret.'
49
52
) ;
50
53
}
54
+ if ( ! params . apiVersion ) {
55
+ params . apiVersion = '5.124' ;
56
+ }
51
57
resolve ( ) ;
52
- } ) . then ( function ( ) {
58
+ } ) . then ( function ( ) {
53
59
return request (
54
60
'oauth.vk.com' ,
55
61
'access_token?client_id=' +
56
62
params . appIds +
57
63
'&client_secret=' +
58
64
params . appSecret +
59
- '&v=5.59&grant_type=client_credentials'
65
+ '&v=' +
66
+ params . apiVersion +
67
+ '&grant_type=client_credentials'
60
68
) ;
61
69
} ) ;
62
70
}
0 commit comments