如何实现自定义 Auth0 登录表单的服务器端代码

How do I implement server-side code for a custom Auth0 login form?

本文关键字:表单 登录 服务器端 代码 Auth0 自定义 何实现 实现      更新时间:2023-09-26

我正在学习构建一个简单的 Web 应用程序,并且正在使用 Auth0.com 来验证应用程序的用户。创建注册表单的说明(https://auth0.com/docs/custom 注册)对我来说非常简单,直到我进入底部的服务器端部分。

它是这样说的:

  1. 服务器端

收到来自客户端的请求后,包含在 消息正文必须使用连接字段进行扩充,即 指示必须将用户存储在哪个连接中。发布该 JSON 到/API/users,如果成功,则创建用户。

POST /api/users
Authorization: Bearer .... access_token ....
{
     email: "...",        // taken from request
     password: "...",
     color: "...",
     food: "...",
     connection: "..."      // added by the server
}

这是什么意思,我该如何完成?如果我在 Azure 托管帐户上创建另一个文件,该怎么称呼它?最后,这是我需要的所有代码吗?谢谢。

POST /api/users
Authorization: Bearer .... access_token ....
{
     email: "...",        // taken from request
     password: "...",
     color: "...",
     food: "...",
     connection: "..."      // added by the server
}

上面的代码片段说明了一个示例 http 请求。如何发送请求取决于您的编程语言。

POST /api/users                             <- the url and request type
Authorization: Bearer .... access_token .... <- Authorization type to put in the http header
{                                           <- from here is the post data
     email: "...",        // taken from request    
     password: "...",
     color: "...",
     food: "...",
     connection: "..."      // added by the server
}

这就是概念。但是,如果你想要特定的代码,你需要说明你正在使用的语言。

@huazhihao所述,实际的服务器端实现取决于您在服务器上使用的语言。

如果你使用JavaScript,我建议你看看AuthO在github上显示的示例。