protected function _oauth2TokenCurl()
  {
    if (self::$_consumer_key === null) {
      throw new CodebirdCredentialsException('To obtain a bearer token, the consumer key must be set.');
    }
    $post_fields = [
      'grant_type' => 'client_credentials'
    ];
    $url        = self::$_endpoints['oauth'] . 'oauth2/token';
    $connection = $this->_getCurlInitialization($url);
    $this->_curl_setopt($connection, CURLOPT_POST, 1);
    $this->_curl_setopt($connection, CURLOPT_POSTFIELDS, $post_fields);

    $this->_curl_setopt($connection, CURLOPT_USERPWD, self::$_consumer_key . ':' . self::$_consumer_secret);
    $this->_curl_setopt($connection, CURLOPT_HTTPHEADER, [
      'Expect:'
    ]);
    $result = $this->_curl_exec($connection);

    // catch request errors
    if ($result === false) {
      throw new CodebirdAuthException('Request error for bearer token: ' . $this->_curl_error($connection));
    }

    // certificate validation results
    $validation_result = $this->_curl_errno($connection);
    $this->_validateSslCertificate($validation_result);

    $httpstatus = $this->_curl_getinfo($connection, CURLINFO_HTTP_CODE);
    $reply = $this->_parseBearerReply($result, $httpstatus);
    return $reply;
  }
protected function _oauth2TokenCurl()
  {
    if (self::$_consumer_key === null) {
      throw new CodebirdCredentialsException('To obtain a bearer token, the consumer key must be set.');
    }
    $post_fields = [
      'grant_type' => 'client_credentials'
    ];
    $url        = self::$_endpoints['oauth'] . 'oauth2/token';
    $connection = $this->_getCurlInitialization($url);
    $this->_curl_setopt($connection, CURLOPT_POST, 1);
    $this->_curl_setopt($connection, CURLOPT_POSTFIELDS, $post_fields);

    $this->_curl_setopt($connection, CURLOPT_USERPWD, self::$_consumer_key . ':' . self::$_consumer_secret);
    $this->_curl_setopt($connection, CURLOPT_HTTPHEADER, [
      'Expect:'
    ]);
    $result = $this->_curl_exec($connection);

    // catch request errors
    if ($result === false) {
      throw new CodebirdAuthException('Request error for bearer token: ' . $this->_curl_error($connection));
    }

    // certificate validation results
    $validation_result = $this->_curl_errno($connection);
    $this->_validateSslCertificate($validation_result);

    $httpstatus = $this->_curl_getinfo($connection, CURLINFO_HTTP_CODE);
    $reply = $this->_parseBearerReply($result, $httpstatus);
    return $reply;
  }
protected function _oauth2TokenCurl ( ) { if ( self :: $ _consumer_key === null ) { throw new CodebirdCredentialsException ( 'To obtain a bearer token, the consumer key must be set.' ) ; } $ post_fields = [ 'grant_type' => 'client_credentials' ] ; $ url = self :: $ _endpoints [ 'oauth' ] . 'oauth2/token' ; $ connection = $ this -> _getCurlInitialization ( $ url ) ; $ this -> _curl_setopt ( $ connection , CURLOPT_POST , 1 ) ; $ this -> _curl_setopt ( $ connection , CURLOPT_POSTFIELDS , $ post_fields ) ; $ this -> _curl_setopt ( $ connection , CURLOPT_USERPWD , self :: $ _consumer_key . ':' . self :: $ _consumer_secret ) ; $ this -> _curl_setopt ( $ connection , CURLOPT_HTTPHEADER , [ 'Expect:' ] ) ; $ result = $ this -> _curl_exec ( $ connection ) ; // catch request errors if ( $ result === false ) { throw new CodebirdAuthException ( 'Request error for bearer token: ' . $ this -> _curl_error ( $ connection ) ) ; } // certificate validation results $ validation_result = $ this -> _curl_errno ( $ connection ) ; $ this -> _validateSslCertificate ( $ validation_result ) ; $ httpstatus = $ this -> _curl_getinfo ( $ connection , CURLINFO_HTTP_CODE ) ; $ reply = $ this -> _parseBearerReply ( $ result , $ httpstatus ) ; return $ reply ; }
Gets the OAuth bearer token, using cURL

@return string The OAuth bearer token
@throws \Exception
Gets the OAuth bearer token using cURL