title: How do i get Instagram Code for Oauth authorisation?
body: <p>I am making desktop app in java for instagram right now and i don't know how to get code from callback url. My app is desktop so my REDIRECT-URI is <a href="http://instagram.com" rel="nofollow">http://instagram.com</a>. So in my app i send a request to <a href="https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&amp;redirect_uri=REDIRECT-URI&amp;response_type=code" rel="nofollow">https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&amp;redirect_uri=REDIRECT-URI&amp;response_type=code</a> and get redirected to instagram.com?code=CODE. And also forgot to mention, I get a code once by my hands a i gave all permissions. So now then i make request i redirected straightly to URL with code.
   How do i get code from callback uri in program in java? This is my code:</p>
  
  <pre><code>static void GetCode()
  {
      try {
          String url = "https://api.instagram.com/oauth/authorize/?client_id=" + ClientId + "&amp;redirect_uri=" + BackUri + "&amp;response_type=code&amp;scope=likes+comments+relationships";
          HttpClient client = new DefaultHttpClient();
          HttpGet request = new HttpGet(url);
          HttpResponse response = client.execute(request);
          BufferedReader rd = new BufferedReader(
                  new InputStreamReader(response.getEntity().getContent()));
  
          StringBuffer result = new StringBuffer();
          String line = "";
          while ((line = rd.readLine()) != null) {
              result.append(line);
          }
  
          System.out.println(result.toString());
  
      }
      catch(Exception e)
      {
          System.out.print("GET CODE ERROR-&gt;"+e.toString());
      }
  
  }
  </code></pre>