https://supertokens.com/ logo
getting otp in test mode
d

derSuchende

04/09/2023, 10:12 AM
Hello, i would ask how to deploy the api_server and how to retrieve OTP code in SoperTokens test mode with PHONE passwordless method. Thank You
r

rp

04/09/2023, 10:15 AM
To retrieve the OTP code in SuperTokens test mode with PHONE passwordless method, you can use the
sendSms
function to log the OTP code to the console. Here is the docs link snippet for how you can use sendSMS: https://supertokens.com/docs/passwordless/sms-delivery/custom-method
d

derSuchende

04/09/2023, 12:24 PM
Thank you very much. Happy Easter
Hello, i tried this code:
Passwordless.init({
        contactMethod: "PHONE",
        flowType: "USER_INPUT_CODE_AND_MAGIC_LINK",
        smsDelivery: {
          override: (originalImplementation) => {
                  return {
                      ...originalImplementation,
                      sendSms: async function ({
                          codeLifetime, // amount of time the code is alive for (in MS)
                          phoneNumber,
                          urlWithLinkCode, // magic link
                          userInputCode, // OTP
                      }) {
                          console.log(userInputCode);
                      }
                  }
              }
          },
      }),
The problem is that the OTP Code is written in the server console and not in the browser console. Is there a way to solve this? Thank you
r

rp

04/11/2023, 12:17 PM
you could save the otp in a variable and the make an API which returns that. The frontend can then call this API to get the OTP
d

derSuchende

04/11/2023, 12:40 PM
Ok, but how can inject this in the default OTP input page?
r

rp

04/11/2023, 12:40 PM
once you have the OTP on the frontend, use JS dom manipulation to inject it into the input box
d

derSuchende

04/11/2023, 12:41 PM
OK, i'lltry, thank you