https://github.com/workos/ruby-magic-link-example
An example Sinatra application demonstrating how to use the WorkOS Ruby SDK to support Magic Link.
https://github.com/workos/ruby-magic-link-example
Last synced: 11 months ago
JSON representation
An example Sinatra application demonstrating how to use the WorkOS Ruby SDK to support Magic Link.
- Host: GitHub
- URL: https://github.com/workos/ruby-magic-link-example
- Owner: workos
- License: mit
- Created: 2020-11-20T18:32:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-28T23:35:17.000Z (over 2 years ago)
- Last Synced: 2025-04-02T20:50:19.137Z (about 1 year ago)
- Language: Ruby
- Size: 12.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ruby-magic-link-example
An example Sinatra application demonstrating how Magic Link works with WorkOS and Ruby.
## Clone and Install
Clone this repo and install dependencies:
```sh
git clone https://github.com/workos-inc/ruby-magic-link-example.git && cd ruby-magic-link-example && bundle install
```
## Configure your environment
1. Grab your [API Key](https://dashboard.workos.com/api-keys).
2. Run `cp .env.example .env` and add your API key. The `workos` gem will read your API key from the ENV variable `WORKOS_API_KEY`. You may also set the API key yourself by adding `WorkOS.key = $YOUR_API_KEY` to `app.rb`.
2. Create an [SSO Connection for the Magic Link](https://dashboard.workos.com/sso/connections).
3. Add a [Redirect URI](https://dashboard.workos.com/sso/configuration) with the value `http://localhost:4567/callback`.
4. Get your [Project ID](https://dashboard.workos.com/sso/configuration).
5. Update `app.rb`:
```ruby
PROJECT_ID = "$YOUR_PROJECT_ID"
REDIRECT_URI = "$YOUR_REDIRECT_URI"
```
## Run the app and log in using SSO
```sh
ruby app.rb
```
Head to `http://localhost:4567` and submit your email. Then, click on the MagicLink
in the email sent from WorkOS to authenticate to the example app.
For more information, see the [WorkOS Ruby SDK documentation](https://docs.workos.com/sdk/ruby).