0

help with this code, it give me a 401 error and I don't find the problem

 Here is my code, I have change the values by xxxxx.
<?php
$time = time();
$consumerkey='xxxxxxxx';
$consumersecret = 'xxxxxx';
/*
$created = date('c');
$nonce = substr(md5(uniqid('nonce_', true)),0,16);
$nonce64 = base64_encode($nonce);
$passwordDigest = base64_encode(sha1($nonce . $created . $consumersecret));
*/
$once1 = sha1(time() + rand(0,10));
$url = 'https://api.login.yahoo.com/oauth/v2/';

$url .= 'get_request_token?oauth_nonce='.$once1;
$url .= '&oauth_timestamp='.$time;

$url .= '&oauth_consumer_key='.$consumerkey;
$url .= '&oauth_signature_method=plaintext';
$url .= '&oauth_signature='.$consumersecret;
$url .= '&oauth_version=1.0';
$url .= '&xoauth_lang_pref="en-us"';
$url .= '&oauth_callback="oob"';


//dpm($url);
$result = drupal_http_request($url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3, $timeout = 30.0);
dpm($result);
//dpm is like print_r
?>
I get this:
 
  •   (String, 69 characters ) oauth_problem=parameter_absent&oauth_parameters...
    • oauth_problem=parameter_absent&oauth_parameters_absent=oauth_callback
  •   (String, 22 characters ) Authorization Required
  •  (String, 3 characters ) 401

Thanks

Oskar

by
2 Replies
  • I have solved it adding a &#39;%26&#39; to the end of my consumersecret. I&#39;m really annoying about this, Only in <span style="text-decoration:underline;">stackoverflow</span> someone speak about it.<br><br>anyway. Thanks, now the second step ;)<br><br>Oskar<br><br>
    0
  • I have my consumersecret appended with &quot;%26&quot; but still getting error Http 401
    0

Recent Posts

in Contacts