HomePhabricator

Support Conduit tokens in ConduitClient

Description

Support Conduit tokens in ConduitClient

Summary: Ref T5955. Allow ConduitClient to use simple token-based authentication.

Test Plan:

$ cat conduit.php
<?php

require_once 'scripts/__init_script__.php';

$args = new PhutilArgumentParser($argv);
$args->parseStandardArguments();

$result = id(new ConduitClient('http://local.phacility.com'))
  ->setConduitToken('api-6br7udiaydzjxorsr4ooggtzissh')
  ->callMethodSynchronous('user.whoami', array());

var_dump($result);
$ php -f conduit.php -- --trace
>>> [0] <conduit> user.whoami() <bytes = 117>
>>> [1] <http> http://local.phacility.com/api/user.whoami
<<< [1] <http> 216,804 us
<<< [0] <conduit> 217,307 us
array(6) {
  ["phid"]=>
  string(30) "PHID-USER-cvfydnwadpdj7vdon36z"
  ["userName"]=>
  string(5) "admin"
  ["realName"]=>
  string(4) "asdf"
  ["image"]=>
  string(85) "http://local.phacility.com/res/1410737307T/phabricator/3eb28cd9/rsrc/image/avatar.png"
  ["uri"]=>
  string(35) "http://local.phacility.com/p/admin/"
  ["roles"]=>
  array(4) {
    [0]=>
    string(5) "admin"
    [1]=>
    string(8) "verified"
    [2]=>
    string(8) "approved"
    [3]=>
    string(9) "activated"
  }
}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5955

Differential Revision: https://secure.phabricator.com/D10987