Get request for Twitter users/show.json


#1

I have an application in Java which I use to connect to Twitter. So far I have used it to connect to Twitter’s STREAM API using a POST, and I have done this successfully.
Now I am trying to get user information using the users/show.json
However I am not sure which way the base signature string should be.

If I try:

    String signatureBaseString = "GET&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fusers%2Fshow.json&oauth_consumer_key%3D" + 
				CONSUMER_KEY + "%26oauth_nonce%3D" + oauthNonce
				+ "%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D" + oauthTimestamp + "%26oauth_token%3D"
				+ ACCESS_TOKEN + "%26oauth_version%3D1.0";

This returns user not found (as I have not specified a user).

However if I add a user to the end:

		String signatureBaseString = "POST&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fusers%2Fshow.json&oauth_consumer_key%3D" + 
		CONSUMER_KEY + "%26oauth_nonce%3D" + oauthNonce
		+ "%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D" + oauthTimestamp + "%26oauth_token%3D"
		+ ACCESS_TOKEN + "%26oauth_version%3D1.0%26screen_name%3D" + screenName;

I receive an authentication error. What am I doing incorrectly?
Thanks


#2

This sounds like there is an error in your OAuth implementation and how it generates the signature.


#3

Agree with @ePirat that this sounds like an OAuth signing issue, however do also note that users/show uses GET rather than POST.

Generally speaking I’d suggest looking at an existing client library (like Twitter4J in the case of Java, for example) as OAuth is usually a solved problem in those cases.