How to generate verification code and then token using passwordless approach in my lambda function

hi
i created my own webapi with 2 end points one is for generate code and other one is for getToken.
what i really want to know is how to generate verification code and then token using passwordless approach in my lambda function.
first i am using this link
var client = new RestClient(“https://mydomain.com/passwordless/start”);
once have code in my email
then i am calling
var client2 = new RestClient(“https://mydomain.com/oauth/token”);
to get token but it is not working
can someone guide me to the correct path.
i appreciate it.

Thanks
Ibrahim