title: YouTube Data V3 API not recognizing localhost url for redirect uri, why?
body: <p>I am trying to test out the <strong>YouTube Data API V3</strong> to Upload a Video to YouTube in C# using the <a href="https://developers.google.com/youtube/v3/code_samples/dotnet#upload_a_video" rel="nofollow noreferrer">example code</a> supplied. </p>
  
  <p>I am using the <strong>OAuth2</strong> method. I have generated a Client ID / Secret successfully. </p>
  
  <p>The issue I am having is that created a standard C# MVC ASP.NET project, and every time I run it it might say for example <a href="http://localhost:5151/" rel="nofollow noreferrer">http://localhost:5151/</a>. </p>
  
  <p>We are on a private network so I usually have to use something like <strong>ngrok</strong> to receive anything from the outside world being sent directly to my server / machine. </p>
  
  <p>Anyways, where was I? So every time I run my application it says in my url box <a href="http://localhost:5151/" rel="nofollow noreferrer">http://localhost:5151/</a> <em>but</em> when I attempt to run the code in the sample I provided above, it fails to validate me as a user because they claim that the redirect uri's I have set up in the Google API dashboard are not the same as the url being used. </p>
  
  <p>So for example, in my Google API Dashboard redirect uri list I have <a href="http://localhost:5151/" rel="nofollow noreferrer">http://localhost:5151/</a>. But the google misdirect uri error that comes back claims that I am running on <a href="http://localhost:6163/" rel="nofollow noreferrer">http://localhost:6163/</a> . </p>
  
  <p>So I think wait, that must be just a fluke. So I run my application again and now in the url it again says what I would assume it should: <a href="http://localhost:5151/" rel="nofollow noreferrer">http://localhost:5151/</a>, but I <em>again</em> get the same google error_mismatch_redirect_uri error but this time with a <strong>different</strong> port: <a href="http://localhost:6621/" rel="nofollow noreferrer">http://localhost:6621/</a>  !! </p>
  
  <p>I'm not sure what settings are on our servers but it looks like in the background my application is starting up on some random port every time and <strong>thus</strong> google thinks the redirect uri's dont match! What can I do to fix this? Am I missing something trivial here?</p>
  
  <p><strong>UPDATE:</strong>
  Tried using <a href="http://localhost:8080" rel="nofollow noreferrer">http://localhost:8080</a> per their <a href="https://developers.google.com/identity/protocols/OAuth2WebServer" rel="nofollow noreferrer">documentation</a>. Still didn't work.</p>