Issues

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

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?

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.

Fixed in trunk r23946

Fixed in release branch 1.11 at r23983