module WorkOS::Passwordless

The Passwordless module provides convenience methods for working with passwordless sessions including the WorkOS Magic Link. You'll need a valid API key.

@see workos.com/docs/sso/configuring-magic-link

Public Class Methods

create_session(options) click to toggle source
# File lib/workos/passwordless.rb, line 43
def create_session(options)
  response = execute_request(
    request: post_request(
      path: '/passwordless/sessions',
      auth: true,
      body: options,
    ),
  )

  hash = JSON.parse(response.body)

  WorkOS::Types::PasswordlessSessionStruct.new(
    id: hash['id'],
    email: hash['email'],
    expires_at: Date.parse(hash['expires_at']),
    link: hash['link'],
  )
end
send_session(session_id) click to toggle source
# File lib/workos/passwordless.rb, line 74
def send_session(session_id)
  response = execute_request(
    request: post_request(
      path: "/passwordless/sessions/#{session_id}/send",
      auth: true,
    ),
  )

  JSON.parse(response.body)
end