trouble sending the passwordless email



  • I am using the php client lib. Here are the steps I have completed successfully:
    $client->register
    $client->startPasswordlesslogin
    Now I want to send the email to the user so they can complete the login.
    At this step I tried using $client->sendEmail($emailTemplate,$request);
    I am getting a 400 error [empty]userIds message: required
    Here is the request payload:
    {"code":"SLsLRsQHmTcdcx5t1zWqHNTLpO1kjRWrM9s7ZNhd1Xk"}

    The code I am sending is the one I received from startPasswordlessLogin(). Am I following the correct steps for my use case? From the manual for POST /api/passwordless/send only the code is required. Why is it asking for the userIds? I don't want the user to have to enter a code at all. Rather I just want them to click on the link in the email to complete the login. Are users required to use a code to complete the login?



  • Are users required to use a code to complete the login?

    Typically, yes. That is what the passwordless login is all about. A one time code is generated and that is delivered (via email or some other means). When it is provided, the code authenticates the user.

    You can send the email using FusionAuth or by sending it yourself.

    Have you reviewed the passwordless guide? That's pretty detailed in terms of stepping you through the process: https://fusionauth.io/docs/v1/tech/guides/passwordless/



  • Yes, I am able to send the email via the FA console. I just don't get why it is complaining about the userIds for the sendEmail() when that is not a required field.

    Is there some logging feature where I can see what exact Posts are working from the console so i can make sure that my code is doing the same thing?



  • I just don't get why it is complaining about the userIds for the sendEmail() when that is not a required field.

    Have you seenthe passwordless guide? You don't want to call sendEmail when trying to send someone a passwordless email.

    Instead, you want to call /api/passwordless/send

    Is there some logging feature where I can see what exact Posts are working from the console so i can make sure that my code is doing the same thing?

    Not really. You can open your browser's dev console and see what the admin UI is doing, but that's not a one to one mapping with the API.



  • I am using the php client. In the documentation (https://github.com/FusionAuth/fusionauth-php-client/blob/master/src/FusionAuth/FusionAuthClient.php) there are 5 function calls that start with the word "send". Here they are:
    public function sendFamilyRequestEmail($request)
    public function sendEmail($emailTemplateId, $request)
    public function sendPasswordlessCode($request) <<<this one works!!
    public function sendTwoFactorCode($request)
    public function sendTwoFactorCodeForLogin($twoFactorId)

    I got it working! As you can see the php client doesn't line up EXACTLY with the passwordless guide.



  • Ah, I see how that could be confusing. Sorry about that. Glad you got it sorted out and it works!


Log in to reply