ZF-10851: It is not possible to set OAuth Realm
Description
I could not figure how to set the OAuth Realm for a Zend_Oauth_Client. The general problem is that all params would exist but are not implemented in the client.
The toHeader function in Zend_Oauth_Token_Access looks as following:
public function toHeader(
$url, Zend_Oauth_Config_ConfigInterface $config, array $customParams = null, $realm = null
) {
As can be seen, the fourth paraemter is $realm. But in Zend_Oauth_Client it is not used as can be seen below.
$oauthHeaderValue = $this->getToken()->toHeader(
$this->getUri(true),
$this->_config,
$this->_getSignableParametersAsQueryString(),
);
It is necessary that the realm can be set for the client, otherwise the whole realm parameter does not make sense and calls to Yahoo OAuth are not possible. I extended the client as following:
$oauthHeaderValue = $this->getToken()->toHeader(
$this->getUri(true),
$this->_config,
$this->_getSignableParametersAsQueryString(),
$this->_getRealm(),
);
I added a getter and a setter for the realm. Like this it works.
Comments
Posted by Adam Lundrigan (adamlundrigan) on 2010-12-20T07:23:16.000+0000
I've attached a fix for this issue. It modifies Zend_Oauth_Config to add a 'realm' attribute, and modifies Zend_Oauth_Client:250 to add realm to the toHeader() call as outlined in reporter's post.
I haven't had much experience yet with using Zend_Oauth, so i'm not entirely certain this is the best way to add the ability to configure the realm. Comments?
Posted by Nicolas Ruflin (ruflin) on 2010-12-20T07:34:23.000+0000
Looks good. That's exactly the way I implemented it and it works. I also think this is the right way to add it.
Thanks for the fix.
Posted by Adam Lundrigan (adamlundrigan) on 2011-05-02T22:54:38.000+0000
Fixed in trunk r23946
Posted by Ralph Schindler (ralph) on 2011-05-03T19:28:14.000+0000
Fixed in release branch 1.11 at r23983