summaryrefslogtreecommitdiffstats
path: root/settings
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-09-04 11:10:42 +0000
committerTom Needham <needham.thomas@gmail.com>2012-09-04 11:10:42 +0000
commit37bb16becb11caf80fd2e4f608e16f7642c76137 (patch)
tree7df37f1878f4707793939402cd7b20dfd2753b25 /settings
parent47eebe5f6c12258cd2536fe2f0d7a9e78ff46ae5 (diff)
downloadnextcloud-server-37bb16becb11caf80fd2e4f608e16f7642c76137.tar.gz
nextcloud-server-37bb16becb11caf80fd2e4f608e16f7642c76137.zip
API: Add callback_fail, add OC_OAuth::init and bespoke request token method
Diffstat (limited to 'settings')
-rw-r--r--settings/oauth.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/settings/oauth.php b/settings/oauth.php
index c6c9be515bf..8dba9b33a53 100644
--- a/settings/oauth.php
+++ b/settings/oauth.php
@@ -6,27 +6,41 @@
*/
require_once('../lib/base.php');
-
// Logic
$operation = isset($_GET['operation']) ? $_GET['operation'] : '';
-$server = new OC_OAuth_Server(new OC_OAuth_Store());
+$server = OC_OAuth_server::init();
+
switch($operation){
case 'register':
-
+
+ // Here external apps can register with an ownCloud
+ if(empty($_GET['name']) || empty($_GET['url'])){
+ // Invalid request
+ echo 401;
+ } else {
+ $callbacksuccess = empty($_GET['callback_success']) ? null : $_GET['callback_success'];
+ $callbackfail = empty($_GET['callback_fail']) ? null : $_GET['callback_fail'];
+ $consumer = OC_OAuth_Server::register_consumer($_GET['name'], $_GET['url'], $callbacksuccess, $callbackfail);
+
+ echo 'Registered consumer successfully! </br></br>Key: ' . $consumer->key . '</br>Secret: ' . $consumer->secret;
+ }
break;
case 'request_token':
+
try {
$request = OAuthRequest::from_request();
- $token = $server->fetch_request_token($request);
+ $token = $server->get_request_token($request);
echo $token;
} catch (OAuthException $exception) {
OC_Log::write('OC_OAuth_Server', $exception->getMessage(), OC_LOG::ERROR);
echo $exception->getMessage();
}
- break;
+
+ break;
case 'authorise';
+
OC_API::checkLoggedIn();
// Example
$consumer = array(
@@ -74,7 +88,8 @@ switch($operation){
OC_Log::write('OC_OAuth_Server', $exception->getMessage(), OC_LOG::ERROR);
echo $exception->getMessage();
}
- break;
+
+ break;
default:
// Something went wrong, we need an operation!
OC_Response::setStatus(400);