我想使用 auth0(用户名/密码和 SMS 代码)实现 2 因素注册。我没有使用 Lock 小部件,而是尝试基于 auth0 API 实现注册。
所以,我现在有以下步骤。
1 注册
POST https://somedomain.eu.auth0.com/dbconnections/signup
{
"client_id":"MY_CLIENT_ID",
"client_secret":"MY_CLIENT_SECRET",
"connection": "Username-Password-Authentication",
"email": "sowhat@what.what",
"username": "sowhat",
"password": "sowhat@what.what",
"phone_number": "+38...56" // I have access to this number
}
响应是创建用户。
2 尝试使用用户名/密码登录
POST https://somedomain.eu.auth0.com/oauth/token
{
"client_id":"MY_CLIENT_ID",
"client_secret":"MY_CLIENT_SECRET",
"audience":"http://localhost",
"email": "sowhat@what.what",
"username": "sowhat",
"password": "sowhat@what.what",
"grant_type":"password"
}
响应是mfa_required
和mfa_token
字符串。
3 请求 mfa 质询
POST https://somedomain.eu.auth0.com/mfa/challenge
{
"client_id":"MY_CLIENT_ID",
"client_secret":"MY_CLIENT_SECRET",
"challenge_type": "oob otp",
"mfa_token": "MFA_TOKEN_FROM_PREVIOUS_STEP"
}
回应是
{
"error": "unsupported_challenge_type",
"error_description": "User is not enrolled with guardian"
}
所以我真的不知道我该如何解决这个问题。我想原因可能是因为用户配置文件中缺少phone_number,但我实际上不知道如何通过Username-Password-Authentication
连接添加它。