namespace shpub;
/**
- * @link http://micropub.net/draft/
- * @link http://indieweb.org/authorization-endpoint
+ * Connect to a micropub server to get an access token.
+ *
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
+ * @link http://cweiske.de/shpub.htm
+ * @link http://micropub.net/draft/
+ * @link http://indieweb.org/authorization-endpoint
*/
class Command_Connect
{
'default' => false,
)
);
+ $cmd->addOption(
+ 'scope',
+ array(
+ 'short_name' => '-s',
+ 'long_name' => '--scope',
+ 'description' => 'Space-separated list of scopes to request'
+ . ' (default: create)',
+ 'action' => 'StoreString',
+ 'default' => 'create',
+ )
+ );
$cmd->addArgument(
'server',
[
);
}
- public function run($server, $user, $newKey, $force)
+ public function run($server, $user, $newKey, $force, $scope)
{
$server = Validator::url($server, 'server');
if ($user === null) {
$state = time();
Log::msg(
"To authenticate, open the following URL:\n"
- . $this->getBrowserAuthUrl($host, $user, $redirect_uri, $state)
+ . $this->getBrowserAuthUrl($host, $user, $redirect_uri, $state, $scope)
);
$authParams = $this->startHttpServer($socketStr);
return $accessToken;
}
- protected function getBrowserAuthUrl($host, $user, $redirect_uri, $state)
+ protected function getBrowserAuthUrl($host, $user, $redirect_uri, $state, $scope)
{
return $host->endpoints->authorization
. '?me=' . urlencode($user)
. '&client_id=' . urlencode(static::$client_id)
. '&redirect_uri=' . urlencode($redirect_uri)
. '&state=' . $state
- . '&scope=post'
+ . '&scope=' . urlencode($scope)
. '&response_type=code';
}