/**
  * {@inheritDoc}
  *
  * @internal The current user endpoint gives a redirection, so we need to
  *     override the HTTP call to avoid redirections.
  */
 protected function fetchUserDetails(TokenCredentials $tokenCredentials, $force = true)
 {
     if (!$this->cachedUserDetailsResponse || $force) {
         try {
             $this->request($this->urlUserDetails(), $tokenCredentials, array('options' => array('allow_redirects' => false)));
         } catch (BadResponseException $e) {
             throw new \Exception($e->getMessage());
         }
         switch ($this->responseType) {
             case 'json':
                 $this->cachedUserDetailsResponse = $this->response->json();
                 break;
             case 'xml':
                 $this->cachedUserDetailsResponse = $this->response->xml();
                 break;
             case 'string':
                 parse_str($this->response->getBody(), $this->cachedUserDetailsResponse);
                 break;
             default:
                 throw new \InvalidArgumentException("Invalid response type [{$this->responseType}].");
         }
     }
     return $this->cachedUserDetailsResponse;
 }