Oauth - percent encoding


#1

I am trying to implement oauth for twitter, just for fun. I am able to run the request token request, and to get the token back, but sometimes I get a 401 response code and, to me, seems related to the fact the signature contains chars like _ or -. Is that possible? Any reason?
private static String encode(String value) {
String encoded = null;
try {
encoded = URLEncoder.encode(value, “UTF-8”);
encoded = encoded.replace("+", “%20”);
encoded = encoded.replace("*", “%2A”);
encoded = encoded.replace("%7E", “~”);
return encoded;
} catch (UnsupportedEncodingException ignore) {
}
return null;
}

thanks