summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-01-07 18:33:17 -0800
committerZach Copley <zach@status.net>2010-01-14 02:41:05 +0000
commit2e23638615275d7aec19b48f0333bbdabb1702ef (patch)
tree9e3886efb8039c9dbfdb6ca0698f98be0ef97efb /actions
parentbcbe013385e991c6b1fa12fc62fc3386b61c93ed (diff)
Action for issuing a request token
Diffstat (limited to 'actions')
-rw-r--r--actions/apioauthrequesttoken.php41
1 files changed, 40 insertions, 1 deletions
diff --git a/actions/apioauthrequesttoken.php b/actions/apioauthrequesttoken.php
index c1ccd4b7d..1bbd7d295 100644
--- a/actions/apioauthrequesttoken.php
+++ b/actions/apioauthrequesttoken.php
@@ -32,6 +32,7 @@ if (!defined('STATUSNET')) {
}
require_once INSTALLDIR . '/lib/api.php';
+require_once INSTALLDIR . '/lib/apioauthstore.php';
/**
* Get an OAuth request token
@@ -43,7 +44,45 @@ require_once INSTALLDIR . '/lib/api.php';
* @link http://status.net/
*/
-class ApiOauthRequestTokenAction extends ApiAction
+class ApiOauthRequestTokenAction extends Action
{
+ /**
+ * Is read only?
+ *
+ * @return boolean false
+ */
+ function isReadOnly()
+ {
+ return false;
+ }
+
+ /**
+ * Class handler.
+ *
+ * @param array $args array of arguments
+ *
+ * @return void
+ */
+ function handle($args)
+ {
+ parent::handle($args);
+
+ $datastore = new ApiStatusNetOAuthDataStore();
+ $server = new OAuthServer($datastore);
+ $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
+ $server->add_signature_method($hmac_method);
+
+ try {
+ $req = OAuthRequest::from_request();
+ $token = $server->fetch_request_token($req);
+ print $token;
+ } catch (OAuthException $e) {
+ common_log(LOG_WARN, $e->getMessage());
+ common_debug(var_export($req, true));
+ header('HTTP/1.1 401 Unauthorized');
+ header('Content-Type: text/html; charset=utf-8');
+ print $e->getMessage() . "\n";
+ }
+ }
}