Ruby logo

Integrate WorkOS using the Ruby SDK

Easily add enterprise features like Single Sign-On (SSO/SAML), Directory Sync (SCIM), Audit Trail (SIEM), and Access Control (IAM) to your Ruby app.

Installation

You can install the WorkOS gem via RubyGems with:

Terminal

gem install workos

If you're using Bundler to manage your application's gems, add the WorkOS gem to your Gemfile:

Gemfile

source 'https://rubygems.org'

gem 'workos'

Usage

Below is an example integration that adds SSO using the Ruby SDK. You can find other examples and more information in our Ruby SDK Docs.

Ruby

WorkOS.key = 'WORKOS_API_SECRET_KEY'

DOMAIN = 'example.com'
PROJECT_ID = 'PROJECT_ID'
REDIRECT_URI = 'REDIRECT_URI'

get '/auth' do
  authorization_url = WorkOS::SSO.authorization_url(
    domain: DOMAIN,
    project_id: PROJECT_ID,
    redirect_uri: REDIRECT_URI,
  )

  redirect authorization_url
end

get '/callback' do
  profile = WorkOS::SSO.profile(
    code: params['code'],
    project_id: PROJECT_ID,
  )

  session[:user] = profile.to_json

  redirect '/'
end

Start Integrating Today

Create an account to begin adding enterprise-ready features to your application today.