Goal: Creating an Oauth Provider for use within a Zend Framework web application.
Process so far: Integrated the Zend Framework OAuth Client (ZF 1.12) with the Google Code OAuth classes [http://code.google.com/p/oauth/]. ZF Client for use as a client in the www site, Google Code OAuth for use in the authentication wrapper in the api site.
Looking for assistance in getting the solution working.
The solution works well for basic requests - unless there are GET parameters in the URL where both frameworks will then generate different signatures therefore breaking the authentication.
Sample code www:
$uri = 'http://oauth.example.com/search?q=something';
$Application = array();
$Application['oauth_consumer_key'] = 'app';
$Application['oauth_consumer_secret'] = 'appsecret';
$token = new Zend_Oauth_Token_Access();
$config = array(
'consumerKey' => $Application['oauth_consumer_key'],
'consumerSecret' => $Application['oauth_consumer_secret'],
);
$client = $token->getHttpClient($config);
$client->setUri($uri);
$client->setMethod(Zend_Http_Client::POST);
$client->setHeaders('Content-Type', 'application/json');
$response = $client->request();
Sample code api:
require_once 'OAuth.php';
$userRequest = OAuthRequest::from_request(null, null, null);
$params = $userRequest->get_parameters();
$params['user_request'] = $userRequest;
$request = $params;
$application = array(
'token' => 'app',
'secret' => 'appsecret',
);
// Test OAuth tokens
$oauthConsumer = new OAuthConsumer($application['token'], $application['secret']);
$oauthToken = null;
$signatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
$signature = $signatureMethod->build_signature(
$request['user_request'],
$oauthConsumer,
$oauthToken
);
// If signatures match, return true
if ($request['oauth_signature'] == $signature) {
return true;
}
return false;
It seems that the Zend_Oauth_Token_Access disregards the custom parameters (see '?q=' above), where the oauth classes consider all parameters. This means when there are no parameters both systems generate the same signature.
I can't seem to get the Zend Oauth client to consider the GET parameters.
Please help?