Skip to content

Commit

Permalink
New patch for issue 83, dealing with oauth_token and signing
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobg@corollarium.com committed Nov 24, 2010
1 parent fc3c49e commit c062c3b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions library/OAuthRequest.php
Expand Up @@ -174,6 +174,7 @@ function signatureBaseString ()
*
* @param string consumer_secret
* @param string token_secret
* @param string token_type
* @exception when not all parts available
* @return string
*/
Expand All @@ -186,11 +187,11 @@ function calculateSignature ( $consumer_secret, $token_secret, $token_type = 'ac
'oauth_nonce'
);

/* removed as per in issue 83
if ($token_type !== false)
// removed as per in issue 83
if ($token_type != 'request')
{
$required[] = 'oauth_token';
} */
}

foreach ($required as $req)
{
Expand Down
8 changes: 4 additions & 4 deletions library/OAuthRequestSigner.php
Expand Up @@ -102,7 +102,7 @@ function setUnsigned ()
* @exception OAuthException2 when there is no oauth relation with the server
* @exception OAuthException2 when we don't support the signing methods of the server
*/
function sign ( $usr_id = 0, $secrets = null, $name = '' )
function sign ( $usr_id = 0, $secrets = null, $name = '', $token_type = null)
{
$url = $this->getRequestUrl();
if (empty($secrets))
Expand All @@ -128,8 +128,8 @@ function sign ( $usr_id = 0, $secrets = null, $name = '' )
$this->setParam('oauth_signature', '');
$this->setParam('oauth_nonce', !empty($secrets['nonce']) ? $secrets['nonce'] : uniqid(''));
$this->setParam('oauth_timestamp', !empty($secrets['timestamp']) ? $secrets['timestamp'] : time());
// removed as mentioned in issue 83
// $this->setParam('oauth_token', $token);
if ($oauth_token != 'request')
$this->setParam('oauth_token', $token);
$this->setParam('oauth_consumer_key', $secrets['consumer_key']);
$this->setParam('oauth_version', '1.0');

Expand All @@ -141,7 +141,7 @@ function sign ( $usr_id = 0, $secrets = null, $name = '' )
$this->setParam('xoauth_body_signature', $body_signature, true);
}

$signature = $this->calculateSignature($secrets['consumer_secret'], $token_secret);
$signature = $this->calculateSignature($secrets['consumer_secret'], $token_secret, $token_type);
$this->setParam('oauth_signature', $signature, true);

$this->signed = true;
Expand Down
6 changes: 3 additions & 3 deletions library/OAuthRequester.php
Expand Up @@ -109,7 +109,7 @@ function doRequest ( $usr_id = 0, $curl_options = array(), $options = array() )
$this->setBody($body);
$curl_options = $this->prepareCurlOptions($curl_options, $extra_headers);
}
$this->sign($usr_id, null, $name);
$this->sign($usr_id, null, $name, 'request');
$text = $this->curl_raw($curl_options);
$result = $this->curl_parse($text);
if ($result['code'] >= 400)
Expand Down Expand Up @@ -156,7 +156,7 @@ static function requestRequestToken ( $consumer_key, $usr_id, $params = null, $m
$uri = $r['request_token_uri'];

$oauth = new OAuthRequester($uri, $method, $params);
$oauth->sign($usr_id, $r);
$oauth->sign($usr_id, $r, '', 'request');
$text = $oauth->curl_raw($curl_options);

if (empty($text))
Expand Down Expand Up @@ -245,7 +245,7 @@ static function requestAccessToken ( $consumer_key, $token, $usr_id, $method = '

OAuthRequestLogger::setRequestObject($oauth);

$oauth->sign($usr_id, $r);
$oauth->sign($usr_id, $r, '', 'access');
$text = $oauth->curl_raw($curl_options);
if (empty($text))
{
Expand Down

0 comments on commit c062c3b

Please sign in to comment.