title: External authentication in ASP.NET core Web API and Angular Client
body: <p>I have an angular application that uses asp.net core Web API. I need to add external authentication for google and facebook sign in so that my web and mobile application can use this web api to authenticate users. I have gone through the documents and tutorials provided for this
  like 
  <a href="https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/" rel="noreferrer">this one</a> and <a href="https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/external-authentication-services" rel="noreferrer">also this</a>
   but none of them are helping me because my web application is on Angular 5.</p>
  
  <p>My actual problem is how to get URL that redirects me to Google or facebook sign in page.</p>
  
  <p>Mostly all of them use scafolded Asp.net mvc application where there is a controller: AccountController with Methods ExternalLogins</p>
  
  <pre><code>GET /api/Account/ExternalLogins?returnUrl=%2F&amp;generateState=true
  </code></pre>
  
  <p>and they say the response will be a json like this: </p>
  
  <pre><code>   [{"name":"Facebook",
    "url":"/api/Account/ExternalLogin?provider=Facebook&amp;response_type=token&amp;client_id=self&amp;redirect_uri=http%3A%2F%2Flocalhost%3A15359%2F&amp;state=QotufgXRptkAfJvcthIOWBnGZydgVkZWsx8YrQepeDk1",
    "state":"QotufgXRptkAfJvcthIOWBnGZydgVkZWsx8YrQepeDk1"}]
  </code></pre>
  
  <p>This JSON is exactly what I need because i need a URL like that to open facebook or google login page. The links above use scaffolded projects and every code written there already that works great for Asp.net web application. But in my case, I have started the web api from scratch and my web application is Angular 5. Also if I tried a scafolded web api project but I could not find any controller called AccountController, nor any Method called ExternalLogins to get the JSON that contains provider name and login page url. It looks like the way its done has been changed in .net core 2.
  The first link above has shown two ways to include GoogleAuthentication in startup class file for Asp.net core 1 and Asp.net Core 2. So there must be something I am missing.</p>
  
  <p>I am using Asp.net core 2.
  I have already got Api keys and secrets and added to startup class file.</p>
  
  <p>I hope I am clear enough. </p>
  
  <p>Please tell me if I need to elaborate more.</p>
  
  <p>Please help. Thanks.</p>