summaryrefslogtreecommitdiffstats
path: root/apps/files_external/ajax
diff options
context:
space:
mode:
authorMichael Gapczynski <GapczynskiM@gmail.com>2012-06-12 11:36:25 -0400
committerMichael Gapczynski <GapczynskiM@gmail.com>2012-06-12 11:36:43 -0400
commit5f80be7664f86115caad1ceac9ea670a7b033029 (patch)
treec76f151aea069a44d440ded7dcf53cad3de3b10d /apps/files_external/ajax
parent8626f04f5d9e591cf616c7a3b536409319f5718c (diff)
downloadnextcloud-server-5f80be7664f86115caad1ceac9ea670a7b033029.tar.gz
nextcloud-server-5f80be7664f86115caad1ceac9ea670a7b033029.zip
Add support for mounting Dropbox in external storage UI
Diffstat (limited to 'apps/files_external/ajax')
-rw-r--r--apps/files_external/ajax/dropbox.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/files_external/ajax/dropbox.php b/apps/files_external/ajax/dropbox.php
new file mode 100644
index 00000000000..5f2ff17e625
--- /dev/null
+++ b/apps/files_external/ajax/dropbox.php
@@ -0,0 +1,41 @@
+<?php
+
+require_once 'Dropbox/autoload.php';
+
+OCP\JSON::checkAppEnabled('files_external');
+OCP\JSON::checkLoggedIn();
+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' => 'Fetching request tokens failed. Verify that your Dropbox app key and secret are correct.')));
+ }
+ 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' => 'Fetching access tokens failed. Verify that your Dropbox app key and secret are correct.')));
+ }
+ }
+ break;
+ }
+ }
+} else {
+ OCP\JSON::error(array('data' => array('message' => 'Please provide a valid Dropbox app key and secret.')));
+}
+
+?> \ No newline at end of file