Magic Auth is a passwordless authentication method that allows users to sign in or sign up via a unique, six digit one-time-use code sent to their email inbox. To verify the code, authenticate the user with Magic Auth.
const magicAuth = { object: 'magic_auth', id: 'magic_auth_01E4ZCR3C56J083X43JQXF3JK5', userId: 'user_01HWWYEH2NPT48X82ZT23K5AX4', email: 'marcelina.davis@example.com', expiresAt: '2021-07-01T19:07:33.155Z', code: '123456', createdAt: '2021-06-25T19:07:33.155Z', updatedAt: '2021-06-25T19:07:33.155Z', };
interface MagicAuthGet the details of an existing Magic Auth code that can be used to send an email to a user for authentication.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const magicAuth = await workos.userManagement.getMagicAuth( 'magic_auth_01E4ZCR3C56J083X43JQXF3JK5', );
Creates a one-time authentication code that can be sent to the user’s email address. The code expires in 10 minutes. To verify the code, authenticate the user with Magic Auth.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const magicAuth = await workos.userManagement.createMagicAuth({ email: 'marcelina@example.com', });