Updating TokenController

From Solution Explorer, navigate to the /Controllers/ folder; then, open the TokenController.cs file and add the following action method:

[HttpPost("Facebook")]public async Task<IActionResult> Facebook([FromBody]ExternalLoginRequestViewModel model){    try    {        var fbAPI_url = "https://graph.facebook.com/v2.10/";        var fbAPI_queryString = String.Format(            "me?scope=email&access_token={0}&fields=id,name,email",             model.access_token);        string result = null;        // fetch the user info from Facebook Graph v2.10        using (var c = new HttpClient())        {            c.BaseAddress = new Uri(fbAPI_url);            var response = await c                .GetAsync(fbAPI_queryString);            if (response.IsSuccessStatusCode)            {                result = await response.Content.ReadAsStringAsync();            } else throw ...

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.