Permalink
Browse files

New patch for issue 83, dealing with oauth_token and signing

  • Loading branch information...
1 parent fc3c49e commit c062c3baad513d418dc78e08d43a9ae8f1986ec9 brunobg@corollarium.com committed Nov 24, 2010
Showing with 11 additions and 10 deletions.
  1. +4 −3 library/OAuthRequest.php
  2. +4 −4 library/OAuthRequestSigner.php
  3. +3 −3 library/OAuthRequester.php
@@ -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
*/
@@ -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)
{
@@ -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))
@@ -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');
@@ -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;
@@ -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)
@@ -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))
@@ -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))
{

0 comments on commit c062c3b

Please sign in to comment.