title: How do I get the Auth Code from the redirect url? OAuth2
body: <p>I'm trying to authenticate my app with an API using OAuth2.0. </p>
  
  <p>I'm new to OAuth and only have a basic understanding of it. I have implemented a way to get the access token and make the requests I want, however my method seems a bit inefficient. It could also be my slight lack of knowledge with http requests in Java. Just as a note, i am using the apache http client. </p>
  
  <p>Currently what im doing to get authorized is I open the user authorization page directly in the browser with:</p>
  
  <pre><code>Desktop.getDesktop().browse(new URL(url.toURI());
  </code></pre>
  
  <p>This then redirects to the redirect url in the browser, with the "code" parameter in the url. </p>
  
  <p>I dont know how to get that url and then retrieve the "code" parameter, so Im just copying it from the url itself and then pasting it into an input field, which then sends a request to retrieve the access token.</p>
  
  <p>So my question is, how do I get rid of that step where the user has to copy and paste the code parameter from the redirect url into my program? </p>
  
  <p>How do I send them to the authorization page and then receive the redirected url to take the code parameter from my program to request the access token?</p>
  
  <p>If someone could point me in the right direction or maybe even show a bit of code, I would appreciate it very much.</p>