Java Failed to validate oauth signature and token


#1

Hi, I am trying to get oauth_token by post to https://api.twitter.com/oauth/request_token.
The header is something as follows:

OAuth oauth_nonce="glxomnct08x0gfialw", oauth_callback="http%3A%2F%2Fwww.baidu.com", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1373014401", oauth_consumer_key="9BFD1XOiVFHrnS7Hw78yA", oauth_signature="Qm2WJtOMYAJ8FpOfBAar5THKbdo%3D", oauth_version="1.0"

which looks similar as the sample on page https://dev.twitter.com/docs/api/1/post/oauth/request_token

OAuth oauth_nonce="K7ny27JTpKVsTgdyLdDfmQQWVLERj2zAK5BslRsqyw", oauth_callback="http%3A%2F%2Fmyapp.com%3A3005%2Ftwitter%2Fprocess_callback", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1300228849", oauth_consumer_key="OqEqJeafRSF11jBMStrZz", oauth_signature="Pc%2BMLdv028fxCErFyi8KXFM%2BddU%3D", oauth_version="1.0"

I generate the oauth_nonce by the following code:
public void setOauth_nonce() {
String base = “1234567890abcdefghijklmnopqrstuvwxyz”;
StringBuffer sb = new StringBuffer();
Random rand = new Random();
for(int i = 0; i < 18; i++){
int num = rand.nextInt(base.length());
sb.append(base.charAt(num));
}
this.oauth_nonce = sb.toString() ;
}


I changed the length as 32, also not work.

The param string is like this: 

POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_callback%3Dhttp%3A%2F%2Fwww.baidu.com%26oauth_consumer_key%3D9BFD1XOiVFHrnS7Hw78yA%26oauth_nonce%3Dglxomnct08x0gfialw%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1373014401%26oauth_version%3D1.0



By the way, Example Request on page https://dev.twitter.com/docs/api/1/post/oauth/request_token looks like this,
what exactly is the body?

Request URL:
POST https://api.twitter.com/oauth/request_token

Request POST Body:
N/A



Any help, I will be really grateful~~