Blame view
sources/apps/files_external/ajax/dropbox.php
1.7 KB
|
03e52840d
|
1 |
<?php |
|
31b7f2792
|
2 |
require_once __DIR__ . '/../3rdparty/Dropbox/autoload.php'; |
|
03e52840d
|
3 4 5 6 |
OCP\JSON::checkAppEnabled('files_external');
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
|
|
6d9380f96
|
7 |
$l = OC_L10N::get('files_external');
|
|
03e52840d
|
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
if (isset($_POST['app_key']) && isset($_POST['app_secret'])) {
$oauth = new Dropbox_OAuth_Curl($_POST['app_key'], $_POST['app_secret']);
if (isset($_POST['step'])) {
switch ($_POST['step']) {
case 1:
try {
if (isset($_POST['callback'])) {
$callback = $_POST['callback'];
} else {
$callback = null;
}
$token = $oauth->getRequestToken();
OCP\JSON::success(array('data' => array('url' => $oauth->getAuthorizeUrl($callback),
'request_token' => $token['token'],
'request_token_secret' => $token['token_secret'])));
} catch (Exception $exception) {
OCP\JSON::error(array('data' => array('message' =>
|
|
6d9380f96
|
26 |
$l->t('Fetching request tokens failed. Verify that your Dropbox app key and secret are correct.'))
|
|
03e52840d
|
27 28 29 30 31 32 33 34 35 36 37 38 |
));
}
break;
case 2:
if (isset($_POST['request_token']) && isset($_POST['request_token_secret'])) {
try {
$oauth->setToken($_POST['request_token'], $_POST['request_token_secret']);
$token = $oauth->getAccessToken();
OCP\JSON::success(array('access_token' => $token['token'],
'access_token_secret' => $token['token_secret']));
} catch (Exception $exception) {
OCP\JSON::error(array('data' => array('message' =>
|
|
6d9380f96
|
39 |
$l->t('Fetching access tokens failed. Verify that your Dropbox app key and secret are correct.'))
|
|
03e52840d
|
40 41 42 43 44 45 46 |
));
}
}
break;
}
}
} else {
|
|
6d9380f96
|
47 |
OCP\JSON::error(array('data' => array('message' => $l->t('Please provide a valid Dropbox app key and secret.'))));
|
|
03e52840d
|
48 |
} |