1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 02:22:57 +01:00

[OAuth] Removing token and token_secret from required params. Only adding to auth header if a value is set. Closes #143

This commit is contained in:
Michael Dowling 2012-09-30 01:18:07 -07:00
parent e6fe489fe8
commit d23fabc762
2 changed files with 14 additions and 2 deletions

View File

@ -46,7 +46,7 @@ class OauthPlugin implements EventSubscriberInterface
}
), array(
'signature_method', 'signature_callback', 'version',
'consumer_key', 'consumer_secret', 'token', 'token_secret'
'consumer_key', 'consumer_secret'
));
}
@ -80,7 +80,9 @@ class OauthPlugin implements EventSubscriberInterface
'oauth_token' => $this->config['token'],
'oauth_version' => $this->config['version'],
) as $key => $val) {
$authString .= $key . '="' . urlencode($val) . '", ';
if ($val) {
$authString .= $key . '="' . urlencode($val) . '", ';
}
}
// Add Authorization header

View File

@ -158,4 +158,14 @@ class OauthPluginTest extends \Guzzle\Tests\GuzzleTestCase
$result = $method->invoke($p, $request, 1335936584);
$this->assertEquals('29f72fa5fc2893972060b28a0df8623c41cbb5d2', $result);
}
public function testDoesNotAddFalseyValuesToAuthorization()
{
unset($this->config['token']);
$p = new OauthPlugin($this->config);
$event = new Event(array('request' => $this->getRequest(), 'timestamp' => self::TIMESTAMP));
$p->onRequestBeforeSend($event);
$this->assertTrue($event['request']->hasHeader('Authorization'));
$this->assertNotContains('oauth_token=', (string) $event['request']->getHeader('Authorization'));
}
}