title: OAuth Twitter to get request_token {"errors":[{"code":32,"message":"Could not authenticate you."}]}
body: <pre><code>static public final String CUSUMER_KEY = "mcIgMJKcyhqFlAHK9batPvRvC";
  static public final String CUSUMER_SECRET = "5PRVECiRPoddsBd70qGBfZZdJVPwWcxiicFf7usfS5nyhg4GGp";
  static public final String ACCESS_TOKEN = "2320954854-eZYObTlxJ3Pqqd0YuGNlWcRQJQ4rNAyvsfsssV7";
  static public final String ACCESS_TOKEN_SECRET = "iOEYAG5yEgRuWRh8MY5AIfwK2f2oF6HF9gAkzArTLQUKS";
  static public final String REQUEST_URL = "https://api.twitter.com/oauth/request_token";
  static public final String ACCESS_URL = "http://api.twitter.com/oauth/access_token";
  static public final String AUTHORIZE_URL = "http://api.twitter.com/oauth/authorize";
  static public final String AUTH_URL = "https://api.twitter.com/oauth/authenticate?oauth_token=";
  static public final String CALL_BACK = "%22http%3A%2F%2Fmyapp.com%3A3005%2Ftwitter%2Fprocess_callback%22";
  public String get_access_token(){
      String ret="";
      try{
          String sg_base_str = "POST&amp;"+ URLEncoder.encode("https://api.twitter.com/oauth/request_token", "UTF-8")+"&amp;";
          String[][] data =
                  {
                          {"oauth_consumer_key"    , CUSUMER_KEY  },
                          {"oauth_nonce"           , oauth_nounce()          },
                          {"oauth_signature"       , ""                       },
                          {"oauth_signature_method", "HMAC-SHA1"        },
                          {"oauth_timestamp"       , oauth_timestamp()        },
                          {"oauth_token"           , ACCESS_TOKEN        },
                          {"oauth_version"         , "1.0"       }
                  };
          for(int i = 0; i &lt; data.length; i++)
          {
              String _26;
  
              if(i + 1 &lt; data.length) {
                  _26 = "%26";
              }
              else _26 = "";
  
              if(data[i][0] != "oauth_signature")
              {
                  sg_base_str += URLEncoder.encode(data[i][0],"UTF-8") + "%3D"
                          +  URLEncoder.encode(data[i][1],"UTF-8") + _26 ;
              }
          }
  
          ret =  hmacDigest(sg_base_str,CUSUMER_SECRET+"&amp;"+ACCESS_TOKEN_SECRET, "HmacSHA1")+"\n\n"+sg_base_str;
  
      } catch (UnsupportedEncodingException e) {
          e.printStackTrace();
      }
      ret=ret.replaceAll("/","%2F");
      ret=ret.replaceAll("=","%3D");
      ret=ret.replaceAll("\\+","%2B");
      return ret;
  }
  
  public String oauth_nounce() {
      String uuid_string = UUID.randomUUID().toString();
      uuid_string = uuid_string.replaceAll("-", "");
      String oauth_nonce = uuid_string;
      return oauth_nonce;
  }
  
  public String oauth_timestamp() {
      long millis = System.currentTimeMillis();
      long secs   = millis / 1000;
  
      return String.valueOf(secs);
  }`public static String hmacDigest(String msg, String keyString, String algo) {
      String digest = null;
      try {
          SecretKeySpec key = new SecretKeySpec((keyString).getBytes("UTF-8"), algo);
          Mac mac = Mac.getInstance(algo);
          mac.init(key);
  
          byte[] bytes = mac.doFinal(msg.getBytes("ASCII"));
  
          String encoded = Base64.encodeToString(bytes, 0);
          digest = encoded;
      } catch (UnsupportedEncodingException e) {
      } catch (InvalidKeyException e) {
      } catch (NoSuchAlgorithmException e) {
      }
      return digest;
  }`
  </code></pre>
  
  <ol>
  <li><p>When I run code to get this: <code>oauth_nonce=252e7f4eee134ac2bf8cc287620ec2d9 oauth_timestamp=1433957398 oauth_signature=vAcm%2FNyc7S1RISe6jk7y8N1knMo%3D</code></p></li>
  <li><p>Then I has <code>POST https://api.twitter.com/oauth/request_token?oauth_consumer_key=mcIgMJKcyhqFlAHK9batPvRvC&amp;oauth_nonce=252e7f4eee134ac2bf8cc287620ec2d9&amp;oauth_signature_method=HMAC-SHA1&amp;oauth_timestamp=1433957398&amp;oauth_token=2320954854-eZYObTlxJ3Pqqd0YuGNlWcRQJQ4rNAyvsfsssV7&amp;oauth_version=1.0&amp;oauth_signature=vAcm%2FNyc7S1RISe6jk7y8N1knMo%3D</code></p></li>
  </ol>
  
  <p>and my result <code>{"errors":[{"code":32,"message":"Could not authenticate you."}]}</code></p>
  
  <p>Tell me why?</p>