简体   繁体   English

如何使用 email 和密码验证我的用户?

[英]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.

相关问题 如何使用哈希密码对用户进行身份验证? - How to authenticate user with hashed password? 如何使用密码的列加密以及在业务逻辑中使用密码盐技术对用户进行身份验证? - How to authenticate user using column encryption of password as well as using password salt technique at business logic? 如何在基于Windows窗体的电子邮件应用程序中验证密码? - How to authenticate the password in an email application built on windows forms? 如何针对盐和哈希密码和用户名对用户进行身份验证? - How to authenticate user against salted and hashed password and username? 如何在 c# selenium chrome 驱动程序中验证(用户/密码)代理 - How to authenticate (user/password) proxy in c# selenium chrome driver 如何通过用户名和密码注册用户并通过会员身份确认密码和电子邮件? - How to register user by username and password and confirm password and email by membership? 如何使用web api验证CRM用户? - how to authenticate CRM user using web api? 如何使用远程API验证用户? - How to Authenticate a user using a remote API? 如何在不使用密码的情况下将电子邮件从MVC4发送到Gmail? - How Can i send the email from the MVC4 to my gmail without using my password? 如何通过ManagementScope使用用户名/密码/域进行身份验证 - How to authenticate using username/password/domain via ManagementScope
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM