public function rescopeUsingTenantId($tenantId) {
    $url = $this->url() . '/tokens';
    $token = $this->token();
    $data = array(
      'auth' => array(
        'tenantId' => $tenantId,
        'token' => array(
          'id' => $token,
        ),
      ),
    );
    $body = json_encode($data);

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

    $client = \HPCloud\Transport::instance();
    $response = $client->doRequest($url, 'POST', $headers, $body);
    $this->handleResponse($response);

    return $this->token();
  }
public function rescopeUsingTenantId($tenantId) {
    $url = $this->url() . '/tokens';
    $token = $this->token();
    $data = array(
      'auth' => array(
        'tenantId' => $tenantId,
        'token' => array(
          'id' => $token,
        ),
      ),
    );
    $body = json_encode($data);

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

    $client = \HPCloud\Transport::instance();
    $response = $client->doRequest($url, 'POST', $headers, $body);
    $this->handleResponse($response);

    return $this->token();
  }
public function rescopeUsingTenantId ( $ tenantId ) { $ url = $ this -> url ( ) . '/tokens' ; $ token = $ this -> token ( ) ; $ data = array ( 'auth' => array ( 'tenantId' => $ tenantId , 'token' => array ( 'id' => $ token , ) , ) , ) ; $ body = json_encode ( $ data ) ; $ headers = array ( 'Accept' => self :: ACCEPT_TYPE , 'Content-Type' => 'application/json' , 'Content-Length' => strlen ( $ body ) , //'X-Auth-Token' => $token, ) ; $ client = \ HPCloud \ Transport :: instance ( ) ; $ response = $ client -> doRequest ( $ url , 'POST' , $ headers , $ body ) ; $ this -> handleResponse ( $ response ) ; return $ this -> token ( ) ; }
Rescope the authentication token to a different tenant.

Note that this will rebuild the service catalog and user information for
the current object, since this information is sensitive to tenant info.

An authentication token can be in one of two states:

- unscoped: It has no associated tenant ID.
- scoped: It has a tenant ID, and can thus access that tenant's services.

This method allows you to do any of the following:

- Begin with an unscoped token, and assign it a tenant ID.
- Change a token from one tenant ID to another (re-scoping).
- Remove the tenant ID from a scoped token (unscoping).

@param string $tenantId
The tenant ID that this present token should be bound to. If this is the
empty string (`''`), the present token will be "unscoped" and its tenant
ID will be removed.

@retval string
@return string
The authentication 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.
Rescope the authentication token to a different tenant .