Custom OTP authentication

I want user to authenticate just using phone number and OTP.

My flow is something like this.

Sign up: Enter Phone -> generate OTP -> verify OTP -> success
Login: Enter Phone -> generate OTP -> verify OTP -> success

After reading around, I can’t find any straight forward way to do it with Parse.

I did understand I need to use Custom Auth, But I cannot find and example of that which I can refer.

Still I tried to use it something like this:

new ParseServer({
  databaseURI: process.env.databaseUri,
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + "/cloud/main.js",
  appId: process.env.organinationId,
  restAPIKey: process.env.organinationSecret,
  javascriptKey: process.env.organinationSecret,
  serverURL: server.api,
  masterKey: process.env.organinationSecret,
  auth: {
    otpAuth: {
      module: CustomAuth
    }
  },
});

I customAuth module I have validateAuthData() and validateAppId() methods. But I have no idea how to integrate it further with parse authentication. I tried to create a user and use _linkWith without any luck.

Can anyone guide how to achieve simple OTP authentication flow?

It looks like that you are in the right direction as you can see here. Could you share the code that you are using for the adapters and for the signing up the user? Do you see any error message?