This example application demonstrates one way to use Stytch within a Ruby application.
This project uses Stytch's backend Ruby SDK, which wraps Stytch's API endpoints.
This application features our Email Magic Links product. You can use this application's source code as a learning resource, or use it as a jumping off point for your own project. We're excited to see what you build with Stytch!
Follow the below steps to get this application running using your own Stytch credentials.
-
Create a Stytch account. A new Stytch project called "My first project" will be created for you.
-
Within your new project, navigate to Redirect URLs, and add
http://localhost:3000/authenticate
as the types Login and Sign-up. -
Next, navigate to API Keys. You will need the
project_id
andsecret
values found on this page.
In your terminal, clone the project and install dependencies:
git clone https://github.com/stytchauth/stytch-ruby-example.git
cd stytch-ruby-example
gem install bundler
Install gems:
bundle install
Next, we'll create your .env
file. Open .env.sample
in the text editor of your choice and set the environment variables using the project_id
and secret
found on API Keys. Leave the STYTCH_PROJECT_ENV
value as test
. When you're done, save it as .env
. This is what a completed .env
file will look like:
HOST="http://localhost:3000"
STYTCH_ENV="test"
STYTCH_PROJECT_ID="project-test-00000000-0000-1234-abcd-abcdef1234"
STYTCH_SECRET="secret-test-12345678901234567890abcdabcd"
After completing all of the above steps, the application can be run with the command:
ruby ./server.rb
The application will be available at http://localhost:3000
, where you'll be able to complete the Email Magic Links flow.
This example app showcases a small portion of what you can accomplish with Stytch. Here are a few ideas to explore:
- Add additional login methods like OAuth or Passwords.
- Secure your app further by building MFA authentication using methods like OTP.
Join the discussion, ask questions, and suggest new features in our Slack community!
Check out the Stytch Forum or email us at [email protected].