2 Formatting code and highlight important part
source | link

I was simply using the wrong oauth_token_secretoauth_token_secret, i should have used the one returned from the access_tokenaccess_token not the request_tokenrequest_token. 

On another note the oauth_verifieroauth_verifier is not needed when accessing the api endpoints.

Thats how the function ended up:

public function doshitAction(){

public function doshitAction(){

$params = array(
    'siteUrl' => 'http://www.appfactory.loc/magento/oauth',
    'requestTokenUrl' => 'http://www.appfactory.loc/magento/oauth/initiate',
    'accessTokenUrl' => 'http://www.appfactory.loc/magento/oauth/token',
    'consumerKey' => '531a7d194914fbd207766bcb022cdc94',
    'consumerSecret' => 'f51868e362b9211d4fde5ebf412080b0',
    'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER
);

// Initiate oAuth consumer
$consumer = new Zend_Oauth_Consumer($params);
// Using oAuth parameters and request Token we got, get access token
$acessToken = new Zend_Oauth_Token_Access;
$acessToken->setParams(array(
    'oauth_token' => 'e3d089e2b420cd3b940c3cf67587a95d',
    'oauth_token_secret' => 'ab2f46861defe6ee5740f7a748301367'
));


// do a request
$restClient = $acessToken->getHttpClient($params);
$restClient->setUri('http://www.appfactory.loc/magento/api/rest/products');
$restClient->setHeaders('Accept', 'application/json');
$restClient->setMethod(Zend_Http_Client::GET);
$response = $restClient->request();
// Here we can see that response body contains json list of products

return $response->getBody(); 


}

}

I was simply using the wrong oauth_token_secret, i should have used the one returned from the access_token not the request_token. On another note the oauth_verifier is not needed when accessing the api endpoints.

Thats how the function ended up:

public function doshitAction(){

$params = array(
    'siteUrl' => 'http://www.appfactory.loc/magento/oauth',
    'requestTokenUrl' => 'http://www.appfactory.loc/magento/oauth/initiate',
    'accessTokenUrl' => 'http://www.appfactory.loc/magento/oauth/token',
    'consumerKey' => '531a7d194914fbd207766bcb022cdc94',
    'consumerSecret' => 'f51868e362b9211d4fde5ebf412080b0',
    'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER
);

// Initiate oAuth consumer
$consumer = new Zend_Oauth_Consumer($params);
// Using oAuth parameters and request Token we got, get access token
$acessToken = new Zend_Oauth_Token_Access;
$acessToken->setParams(array(
    'oauth_token' => 'e3d089e2b420cd3b940c3cf67587a95d',
    'oauth_token_secret' => 'ab2f46861defe6ee5740f7a748301367'
));


// do a request
$restClient = $acessToken->getHttpClient($params);
$restClient->setUri('http://www.appfactory.loc/magento/api/rest/products');
$restClient->setHeaders('Accept', 'application/json');
$restClient->setMethod(Zend_Http_Client::GET);
$response = $restClient->request();
// Here we can see that response body contains json list of products

return $response->getBody();

}

I was simply using the wrong oauth_token_secret, i should have used the one returned from the access_token not the request_token. 

On another note the oauth_verifier is not needed when accessing the api endpoints.

Thats how the function ended up:

public function doshitAction(){

$params = array(
    'siteUrl' => 'http://www.appfactory.loc/magento/oauth',
    'requestTokenUrl' => 'http://www.appfactory.loc/magento/oauth/initiate',
    'accessTokenUrl' => 'http://www.appfactory.loc/magento/oauth/token',
    'consumerKey' => '531a7d194914fbd207766bcb022cdc94',
    'consumerSecret' => 'f51868e362b9211d4fde5ebf412080b0',
    'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER
);

// Initiate oAuth consumer
$consumer = new Zend_Oauth_Consumer($params);
// Using oAuth parameters and request Token we got, get access token
$acessToken = new Zend_Oauth_Token_Access;
$acessToken->setParams(array(
    'oauth_token' => 'e3d089e2b420cd3b940c3cf67587a95d',
    'oauth_token_secret' => 'ab2f46861defe6ee5740f7a748301367'
));


// do a request
$restClient = $acessToken->getHttpClient($params);
$restClient->setUri('http://www.appfactory.loc/magento/api/rest/products');
$restClient->setHeaders('Accept', 'application/json');
$restClient->setMethod(Zend_Http_Client::GET);
$response = $restClient->request();
// Here we can see that response body contains json list of products

return $response->getBody(); 


}
1
source | link

I was simply using the wrong oauth_token_secret, i should have used the one returned from the access_token not the request_token. On another note the oauth_verifier is not needed when accessing the api endpoints.

Thats how the function ended up:

public function doshitAction(){

$params = array(
    'siteUrl' => 'http://www.appfactory.loc/magento/oauth',
    'requestTokenUrl' => 'http://www.appfactory.loc/magento/oauth/initiate',
    'accessTokenUrl' => 'http://www.appfactory.loc/magento/oauth/token',
    'consumerKey' => '531a7d194914fbd207766bcb022cdc94',
    'consumerSecret' => 'f51868e362b9211d4fde5ebf412080b0',
    'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER
);

// Initiate oAuth consumer
$consumer = new Zend_Oauth_Consumer($params);
// Using oAuth parameters and request Token we got, get access token
$acessToken = new Zend_Oauth_Token_Access;
$acessToken->setParams(array(
    'oauth_token' => 'e3d089e2b420cd3b940c3cf67587a95d',
    'oauth_token_secret' => 'ab2f46861defe6ee5740f7a748301367'
));


// do a request
$restClient = $acessToken->getHttpClient($params);
$restClient->setUri('http://www.appfactory.loc/magento/api/rest/products');
$restClient->setHeaders('Accept', 'application/json');
$restClient->setMethod(Zend_Http_Client::GET);
$response = $restClient->request();
// Here we can see that response body contains json list of products

return $response->getBody();

}