diff options
author | Brion Vibber <brion@pobox.com> | 2010-09-27 12:24:10 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-09-27 12:24:10 -0700 |
commit | eeaab2bc0072a7f836000c1d817d59c663423998 (patch) | |
tree | 91618dbfc3670937eb6aa73540724abc6072625d /plugins/YammerImport/lib/yammerrunner.php | |
parent | ebbbaba378bbe174ceb5e76477db89ef647304e5 (diff) |
Work in progress on fixing auth... looks like the iframe doesn't work though. Sigh.
Diffstat (limited to 'plugins/YammerImport/lib/yammerrunner.php')
-rw-r--r-- | plugins/YammerImport/lib/yammerrunner.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/plugins/YammerImport/lib/yammerrunner.php b/plugins/YammerImport/lib/yammerrunner.php index e0aadff2c..aee6b17e1 100644 --- a/plugins/YammerImport/lib/yammerrunner.php +++ b/plugins/YammerImport/lib/yammerrunner.php @@ -123,7 +123,7 @@ class YammerRunner public function requestAuth() { if ($this->state->state != 'init') { - throw ServerError("Cannot request Yammer auth; already there!"); + throw new ServerException("Cannot request Yammer auth; already there!"); } $data = $this->client->requestToken(); @@ -135,7 +135,22 @@ class YammerRunner $this->state->modified = common_sql_now(); $this->state->update($old); - return $this->client->authorizeUrl($this->state->oauth_token); + return $this->getAuthUrl(); + } + + /** + * When already in requesting-auth state, grab the URL to send the user to + * to complete OAuth setup. + * + * @return string URL + */ + function getAuthUrl() + { + if ($this->state() == 'requesting-auth') { + return $this->client->authorizeUrl($this->state->oauth_token); + } else { + throw new ServerException('Cannot get Yammer auth URL when not in requesting-auth state!'); + } } /** @@ -152,7 +167,7 @@ class YammerRunner public function saveAuthToken($verifier) { if ($this->state->state != 'requesting-auth') { - throw ServerError("Cannot save auth token in Yammer import state {$this->state->state}"); + throw new ServerException("Cannot save auth token in Yammer import state {$this->state->state}"); } $data = $this->client->accessToken($verifier); |