title: Unable to exchange OAuth auth code for access token
body: <p>I'm just trying to make a simple app, but I can't even get past authenticating the user. I am using the Google OAuth Client Library for Java.<br>
  These are the current steps I am taking:</p>
  
  <ol>
  <li>Start local web server to listen for the loopback response after the OAuth authentication.</li>
  <li><p>Generate the auth URL:</p>
  
  <pre><code>String url = new AuthorizationCodeRequestUrl(AUTH_URL, CLIENT_ID)   
          .setScopes(scopes) // Contains https://www.googleapis.com/auth/drive.readonly
          .setRedirectUri(LOCALHOST + r.getPort()) // Port of local web server
          .build();
  </code></pre></li>
  <li>Use URL to authenticate account.</li>
  <li>Google returns auth code.</li>
  <li><p>Exchange auth code for access token.</p>
  
  <pre><code>TokenResponse token = new AuthorizationCodeTokenRequest(...)
  .setRedirectUri("http://localhost") // &lt;--
  .setClientAuthentication(getClientAuth()) // ClientParametersAuthentication object
  .execute();
  </code></pre></li>
  </ol>
  
  <p>This is where my problem occurs. No matter what value I put in for <code>redirect_uri</code>, I <em>always</em> get <code>{"error":"redirect_uri_mismatch","error_description":"Bad Request"}</code> in return.<br>
  Searching Google for the error, every single result says that it's because the <code>redirect_uri</code> I sent is not registered in the API console.<br>
  When I download the credentials json file, the <code>redirect_uris</code> section contains <code>"urn:ietf:wg:oauth:2.0:oob","http://localhost"</code>, but it's all the same error no matter what I put in.</p>
  
  <p>I went to the Credentials section of the project to fix it, but since this is an installed application, creating credentials for the project gives me <strong>no</strong> option to set any redirect uris. The only way to get access to changing redirect_uris are to create the credentials for "Web application," but this isn't a web application and I don't have a domain it can redirect to.</p>
  
  <p>So I'm stuck, redirect_uri options are not available to me and no value that I use works, I honestly don't know what else to try. What steps can I take to fix this?</p>