@@ -37,7 +37,17 @@ class Dropbox implements Simulator
37
37
*
38
38
* @var string
39
39
*/
40
- protected $ token ;
40
+ private $ appKey ;
41
+
42
+ /**
43
+ * @var string
44
+ */
45
+ private $ appSecret ;
46
+
47
+ /**
48
+ * @var string
49
+ */
50
+ protected $ refreshToken ;
41
51
42
52
/**
43
53
* Remote path
@@ -60,16 +70,6 @@ class Dropbox implements Simulator
60
70
*/
61
71
protected $ time ;
62
72
63
- /**
64
- * @var string
65
- */
66
- private $ appKey ;
67
-
68
- /**
69
- * @var string
70
- */
71
- private $ appSecret ;
72
-
73
73
/**
74
74
* (non-PHPDoc)
75
75
*
@@ -85,12 +85,12 @@ public function setup(array $config)
85
85
}
86
86
87
87
// check for mandatory options
88
- $ this ->validateConfig ($ config , ['token ' , 'path ' , 'appKey ' , 'appSecret ' ]);
88
+ $ this ->validateConfig ($ config , ['refreshToken ' , 'path ' , 'appKey ' , 'appSecret ' ]);
89
89
90
- $ this ->time = time ();
91
- $ this ->token = $ config ['token ' ];
92
- $ this ->appKey = $ config ['appKey ' ];
93
- $ this ->appSecret = $ config ['appSecret ' ];
90
+ $ this ->time = time ();
91
+ $ this ->refreshToken = $ config ['refreshToken ' ];
92
+ $ this ->appKey = $ config ['appKey ' ];
93
+ $ this ->appSecret = $ config ['appSecret ' ];
94
94
// make sure the path contains a leading slash
95
95
$ this ->path = new Path (Util \Path::withLeadingSlash ($ config ['path ' ]), $ this ->time );
96
96
@@ -179,7 +179,14 @@ protected function createCollector(Target $target) : Collector
179
179
protected function createClient () : DropboxApi \Dropbox
180
180
{
181
181
if (!$ this ->client ) {
182
- $ app = new DropboxApi \DropboxApp ($ this ->appKey , $ this ->appSecret , $ this ->token );
182
+ $ app = new DropboxApi \DropboxApp ($ this ->appKey , $ this ->appSecret );
183
+ $ client = new DropboxApi \Dropbox ($ app );
184
+ $ authHelper = $ client ->getAuthHelper ();
185
+ $ token = $ authHelper ->getRefreshedAccessToken (
186
+ new DropboxApi \Models \AccessToken (['refresh_token ' => $ this ->refreshToken ])
187
+ );
188
+
189
+ $ app = new DropboxApi \DropboxApp ($ this ->appKey , $ this ->appSecret , $ token ->getToken ());
183
190
$ this ->client = new DropboxApi \Dropbox ($ app );
184
191
}
185
192
return $ this ->client ;
0 commit comments