I want email or phonenumber login .in default Web Api have username authentication i don't know how to customize that.this is my mvc code.i just call web api here in https://localhost:44327/Token
[AllowAnonymous]
//[ValidateAntiForgeryToken][HttpPost]
public async Task
{
/*This will depend totally on how you will get access to the identity provider and get your token, this is just a sample of how it would be done*/
/*Get Access Token Start*/
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("https://localhost:44327/Token");
var postData = new List
postData.Add(new KeyValuePair
postData.Add(new KeyValuePair
postData.Add(new KeyValuePair
postData.Add(new KeyValuePair
HttpContent content = new FormUrlEncodedContent(postData);
HttpResponseMessage response = await httpClient.PostAsync("https://localhost:44327/Token", content);
// response.EnsureSuccessStatusCode();
string AccessToken = response.Content.ReadAsStringAsync().Result;
//string AccessToken = /*Newtonsoft.Json.*/JsonConvert.DeserializeObject
/*Get Access Token End*/
if (AccessToken.Length >= 200)
{
TempData["userid"] = "userid";
TempData["name"] = model.UserName;
return RedirectToAction("Home");
}
ModelState.AddModelError("Username", "Username and password is not valid");
return View(model);
}

Sachin SinghRank #66 · 26.2K reputationPosted Apr 30, 2021, 2:52 AM EDT
Salman BegRank #284 · 8.8K reputationPosted Apr 29, 2021, 1:21 AM EDT
selvi jpRank #4,123 · 364 reputationPosted Apr 29, 2021, 1:56 AM EDT