public function authenticate(array $ops) {
    $url = $this->url() . '/tokens';
    $envelope = array(
      'auth' => $ops,
    );

    $body = json_encode($envelope);

    $headers = array(
      'Content-Type' => 'application/json',
      'Accept' => self::ACCEPT_TYPE,
      'Content-Length' => strlen($body),
    );

    //print $body . PHP_EOL;

    $client = \HPCloud\Transport::instance();

    $response = $client->doRequest($url, 'POST', $headers, $body);

    $this->handleResponse($response);


    return $this->token();
  }
public function authenticate(array $ops) {
    $url = $this->url() . '/tokens';
    $envelope = array(
      'auth' => $ops,
    );

    $body = json_encode($envelope);

    $headers = array(
      'Content-Type' => 'application/json',
      'Accept' => self::ACCEPT_TYPE,
      'Content-Length' => strlen($body),
    );

    //print $body . PHP_EOL;

    $client = \HPCloud\Transport::instance();

    $response = $client->doRequest($url, 'POST', $headers, $body);

    $this->handleResponse($response);


    return $this->token();
  }
public function authenticate ( array $ ops ) { $ url = $ this -> url ( ) . '/tokens' ; $ envelope = array ( 'auth' => $ ops , ) ; $ body = json_encode ( $ envelope ) ; $ headers = array ( 'Content-Type' => 'application/json' , 'Accept' => self :: ACCEPT_TYPE , 'Content-Length' => strlen ( $ body ) , ) ; //print $body . PHP_EOL; $ client = \ HPCloud \ Transport :: instance ( ) ; $ response = $ client -> doRequest ( $ url , 'POST' , $ headers , $ body ) ; $ this -> handleResponse ( $ response ) ; return $ this -> token ( ) ; }
Send an authentication request.

@remark EXPERT: This allows authentication requests at a low level. For simple
authentication requests using account number or username, see the
authenticateAsUser() and authenticateAsAccount() methods.

Here is an example of username/password-based authentication done with
the authenticate() method:
@code
<?php
$cs = new \HPCloud\Services\IdentityServices($url);
$ops = array(
'passwordCredentials' => array(
'username' => $username,
'password' => $password,
),
'tenantId' => $tenantId,
);
$token = $cs->authenticate($ops);
?>
@endcode

Note that the same authentication can be done by authenticateAsUser().

@param array $ops
An associative array of authentication operations and their respective
parameters.
@retval string
@return string
The token. This is returned for simplicity. The full response is used
to populate this object's service catalog, etc. The token is also
retrievable with token().
@throws HPCloud::Transport::AuthorizationException
If authentication failed.
@throws HPCloud::Exception
For abnormal network conditions. The message will give an indication as
to the underlying problem.
Send an authentication request .