title: Google JWT Authentication with AspNet Core 2.0
body: <p>I am trying to integrate google authentication in my ASP.NET Core 2.0 web api and I cannot figure out how to get it to work.</p>
  
  <p>I have this code in my Startup.cs <code>ConfigureServices</code>:</p>
  
  <pre><code>services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;()
  .AddDefaultTokenProviders();
  
  services.AddAuthentication()
  .AddGoogle(googleOptions =&gt; 
   {
       googleOptions.ClientId = Configuration["Authentication:Google:ClientId"];
       googleOptions.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
  });
  </code></pre>
  
  <p>And this in <code>Configure(IApplicationBuilder app, IHostingEnvironment env)</code>:</p>
  
  <pre><code> app.UseAuthentication();
  </code></pre>
  
  <p>When I navigate to an <code>Authorized</code> endpoint, the result is a <code>302 Found</code> because presumably it is redirecting to some login endpoint (which I never created). How do I prevent the redirection and just have the API expect a token and return a <code>401</code> if no token is provided? </p>