Hi Guys,
I am facing a problem in OAuth during signing request for request
token. I am using HMAC-SHA1 as signature method. I came to know that
for this method, we can use the website's consumer secret as the
signature. I tried this. But I am getting the following message.
"Signature_invalid".
And can you tell me how to generate oauth_nonce parameter value. Can
it be any random value.?.
I am using AJAX to send a request to the server.
For your reference, I am attaching my code below. Please correct my
code if there are any errors.
Thanks.
<html>
<body>
<script type="text/javascript">
function ajaxFunction(){
var xmlHttp;
try{
xmlHttp=new XMLHttpRequest();
}catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}catch (e) {
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}catch (e){
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4) {
alert('o/p '+xmlHttp.responseText);
}
}
xmlHttp.open("post", "https://www.google.com/accounts/
OAuthGetRequestToken", true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-
urlencoded");
xmlHttp.setRequestHeader("Authorization", "OAuth");
var timeStamp = parseInt((new Date().getTime())/1000);
var nonce = "";
var key = "my_consumer_key"; // I have removed my consumer key here.
var secret = "adfaf"; // I have removed my consumer secret here.
nonce = "4572d6"+ timeStamp;
//}
//var nonce = parseInt(Math.round((max-min) * Math.random() + min));
var params = "oauth_consumer_key="+key+"&oauth_signature_method=HMAC-
SHA1&oauth_signature="+secret+"&oauth_timestamp="+timeStamp
+"&oauth_nonce="+nonce+"&oauth_version=1.0&scope=http://www.google.com/
m8/feeds/";
xmlHttp.send(params);
}
</script>
<input type="button" onclick="ajaxFunction()" value="click"
name="username" />
</body>
</html>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"OAuth" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/oauth?hl=en
-~----------~----~----~----~------~----~------~--~---