@@ -14,32 +14,36 @@ var METHOD = 'POST';
14
14
var QcloudSDK = function ( ) {
15
15
this . secretKey = '' ;
16
16
this . secretId = '' ;
17
+ this . token = '' ;
17
18
}
18
19
19
20
QcloudSDK . prototype . config = function ( userConfig ) {
20
21
checkUserConfig ( userConfig )
21
22
22
23
this . secretKey = userConfig . secretKey ;
23
24
this . secretId = userConfig . secretId ;
25
+ this . token = userConfig . token ;
24
26
}
25
27
26
28
QcloudSDK . prototype . request = function ( actionName , params , callback ) {
27
29
checkUserConfig ( {
28
30
secretKey : this . secretKey ,
29
- secretId : this . secretId
31
+ secretId : this . secretId ,
32
+ token : this . token ,
30
33
} )
31
34
32
35
params = params || { } ;
33
36
var timestamp = Math . ceil ( ( new Date ( ) - 0 ) / 1000 ) ;
34
37
var nonce = _ . random ( 1000000 ) ;
35
- var signature = createSignature ( actionName , nonce , timestamp , params , this . secretKey , this . secretId ) ;
38
+ var signature = createSignature ( actionName , nonce , timestamp , params , this . secretKey , this . secretId , this . token ) ;
36
39
37
40
var requestData = _ . assign ( {
38
41
'Action' : actionName ,
39
42
'Timestamp' : timestamp ,
40
43
'Nonce' : nonce ,
41
44
'SecretId' : this . secretId ,
42
45
'Signature' : signature ,
46
+ 'Token' : this . token
43
47
} , params )
44
48
45
49
requestData = commonUtils . serialize ( requestData )
@@ -67,12 +71,13 @@ function checkUserConfig(userConfig) {
67
71
}
68
72
}
69
73
70
- function createSignature ( actionName , nonce , timestamp , params , secretKey , secretId ) {
74
+ function createSignature ( actionName , nonce , timestamp , params , secretKey , secretId , token ) {
71
75
var originObject = _ . assign ( {
72
76
'Action' : actionName ,
73
77
'Nonce' : nonce ,
74
78
'SecretId' : secretId ,
75
- 'Timestamp' : timestamp
79
+ 'Timestamp' : timestamp ,
80
+ 'Token' : token
76
81
} , params ) ;
77
82
var sortedObject = commonUtils . sortObject ( originObject ) ;
78
83
var serializeString = commonUtils . serialize ( sortedObject ) ;
0 commit comments