'\HPCloud\Transport\CURLTransport', 'transport.timeout' => 240, //'transport.debug' => 1, 'transport.ssl.verify' => 0, ); \HPCloud\Bootstrap::useAutoloader(); \HPCloud\Bootstrap::setConfiguration($config); $help = "Authenticate against HPCloud Identity Services. You can authenticate either by account number and access key, or (by using the -u flag) by username, password. While Tenant ID is optional, it is recommended. In both cases, you must supply a URL to the Identity Services endpoint. "; $usage = "php {$argv[0]} [-u] ID SECRET URL [TENANT_ID]"; if ($argc > 1 && $argv[1] == '--help') { print PHP_EOL . "\t" . $usage . PHP_EOL; print PHP_EOL . $help . PHP_EOL; exit(1); } elseif ($argc < 4) { print 'ID, Key, and URL are all required.' . PHP_EOL; print $usage . PHP_EOL; exit(1); } $asUser = FALSE; $offset = 0; if ($argv[1] == '-u') { $asUser = TRUE; ++$offset; } $user = $argv[1 + $offset]; $key = $argv[2 + $offset]; $uri = $argv[3 + $offset]; $tenantId = NULL; if (!empty($argv[4 + $offset])) { $tenantId = $argv[4 + $offset]; } /* $store = ObjectStorage::newFromSwiftAuth($user, $key, $uri); $token = $store->token(); */ $cs = new IdentityServices($uri); if ($asUser) { $token = $cs->authenticateAsUser($user, $key, $tenantId); } else { $token = $cs->authenticateAsAccount($user, $key, $tenantId); } if (empty($token)) { print "Authentication seemed to succeed, but no token was returned." . PHP_EOL; exit(1); } $t = "You are logged in as %s with token %s (good until %s)." . PHP_EOL; $tokenDetails = $cs->tokenDetails(); $user = $cs->user(); printf($t, $user['name'], $cs->token(), $tokenDetails['expires']); print "The following services are available on this account:" . PHP_EOL; $services = $cs->serviceCatalog(); foreach ($services as $service) { print "\t" . $service['name'] . PHP_EOL; } //print_r($services);