parent::handle($args);
try {
$req = OAuthRequest::from_request();
- $server = common_oauth_server();
+ $server = omb_oauth_server();
$token = $server->fetch_access_token($req);
print $token;
} catch (OAuthException $e) {
return;
}
# success!
- common_redirect(common_local_url('all',
- array('nickname' =>
- $nickname)));
+ $url = common_get_returnto();
+ if ($url) {
+ # We don't have to return to it again
+ common_set_returnto(NULL);
+ } else {
+ $url = common_local_url('all',
+ array('nickname' =>
+ $nickname));
+ }
+ common_redirect($url);
} else {
$this->show_form(_t('Incorrect username or password.'));
}
parent::handle($args);
try {
$req = OAuthRequest::from_request();
- $server = common_oauth_server();
+ $server = omb_oauth_server();
$token = $server->fetch_request_token($req);
print $token;
} catch (OAuthException $e) {
try {
$req = $this->get_request();
$server = common_oauth_server();
- list($consumer, $token) = $server->verify_request($req);
+ $server->get_version($req);
+ $consumer = $server->get_consumer($req);
+ $token = $server->get_token($req, $consumer, "request");
+ $server->check_signature($req, $consumer, $token);
} catch (OAuthException $e) {
$this->clear_request();
common_server_error($e->getMessage());
if (common_logged_in()) {
$this->show_form($req);
} else {
- common_return_to(common_local_url('userauthorization'));
+ # Go log in, and then come back
+ common_set_returnto(common_local_url('userauthorization'));
common_redirect(common_local_url('login'));
}
}
if (!$req) {
# XXX: may have an uncaught exception
$req = OAuthRequest::from_request();
- $this->store_request($req);
+ if ($req) {
+ $this->store_request($req);
+ }
}
return $req;
}
function send_authorization() {
$req = $this->get_request();
+
if (!$req) {
common_user_error(_t('No authorization request!'));
return;
use the openidenabled.com libraries for OpenID auth sometime in the
future. Note that this is no longer distributed separately; it's only
in the openidenabled.com OpenID PHP tarball.
-
+ http://openidenabled.com/php-openid/
+- OAuth.php from http://oauth.googlecode.com/svn/code/php/
+- markdown.php from http://michelf.com/projects/php-markdown/
class LaconicaOAuthDataStore extends OAuthDataStore {
- # We just keep a record of who's contacted us
+ # We keep a record of who's contacted us
function lookup_consumer($consumer_key) {
$con = new Consumer('key', $consumer_key);
if (!defined('LACONICA')) { exit(1); }
require_once('OAuth.php');
+require_once(INSTALLDIR.'lib/oauthstore.php');
define('OAUTH_NAMESPACE', 'http://oauth.net/core/1.0/');
define('OMB_NAMESPACE', 'http://openmicroblogging.org/protocol/0.1');
return $con;
}
+function omb_oauth_server() {
+ static $server = null;
+ if ($server) {
+ $server = new OAuthServer(new LaconicaOAuthStore());
+ }
+ return $server;
+}
+
function omb_hmac_sha1() {
static $hmac_method = NULL;
if (!$hmac_method) {
return $enc;
}
+function common_set_returnto($url) {
+ common_ensure_session();
+ $_SESSION['returnto'] = $url;
+}
+
+function common_get_returnto() {
+ common_ensure_session();
+ return $_SESSION['returnto'];
+}
+
function common_timestamp() {
return date('YmdHis');
}