[英]How to Authenticate my user using email and password?
The title is basically what I need, I have been trying for ages doing that without any success.标题基本上是我需要的,我已经尝试了很长时间,但没有成功。 I have this Azure Function App, where I'm trying to authenticate my user by email and password:我有这个 Azure Function 应用程序,我试图通过 email 和密码验证我的用户:
[FunctionName(nameof(Auth))]
public static async Task<IActionResult> Auth(
[HttpTrigger(AuthorizationLevel.Admin, "POST", Route = "auth")] HttpRequest req,
[Table("User", Connection = "AzureWebJobsStorage")] TableClient tdClient,
ILogger log)
{
string url = String.Format("http://localhost:7235/api/");
HttpMessageHandler handler = new HttpClientHandler()
{
};
var httpClient = new HttpClient(handler)
{
BaseAddress = new Uri(url),
Timeout = new TimeSpan(0, 2, 0)
};
httpClient.DefaultRequestHeaders.Add("ContentType", "application/json");
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes("roy.mitchel@somecompany.com:pass1234");
string val = System.Convert.ToBase64String(plainTextBytes);
httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + val);
HttpResponseMessage response = httpClient.GetAsync(url).Result;
return new OkObjectResult(response);
}
If someone could help me with that, would be amazing, my users are stored in Azure Table.如果有人可以帮助我,那就太棒了,我的用户存储在 Azure 表中。 What I basically need is inser the email and password of a user, and retrieve all the details.我基本上需要的是插入用户的 email 和密码,并检索所有详细信息。
Thanks谢谢
If I got your question, you just need to replace "Bearer" with "basic".如果我有您的问题,您只需将“Bearer”替换为“basic”即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.