I am getting very inconsistent results with the authentication.
It works 'sometimes' from IE and never from Firefox (well not yet it is random). I am using the modified code below. I am always hitting the same page from an external iFrame. I am dumping all the variables and cannot understand why the signatures matche sometimes and not others. The only changes in the $base_string seem to be the expected changes in oauth_nonce, oauth_timestamp, and opensocial_token.
Any ideas as to what stupid thing I am missing here?
Thanks in advance,
Clint
$remote_signature = $_GET['oauth_signature'];
$url = strtolower( $_SERVER['SCRIPT_URI'] ); //for debugging. I have tried hard coded page value also
unset( $_GET['oauth_signature'] );
ksort( $_GET );
$param_string = '';
$first = 0;
foreach ($_GET as $key => $value) {
if ($first == 1) {
$param_string .= '&'.$key.'='.urlencode($value);
}
else {
$param_string .= $key.'='.urlencode($value);
}
$first = 1;
}
$base_string = 'GET&'.
urlencode( $url ) . '&'.
//urlencode( http_build_query( $_GET ) );
urlencode( $param_string );
$secret = $app->getSecret() . '&';
$local_signature = base64_encode( hash_hmac( "sha1", $base_string, $secret, TRUE ) );
if ( $remote_signature == $local_signature) {
echo 'success ';
print "url = $url secret = $secret remote = $remote_signature local = $local_signature base_string = $base_string\n";
}
else {
echo 'not validated! ';
print "url = $url secret = $secret remote = $remote_signature local = $local_signature base_string = $base_string\n";
}