Stytch Ruby Gem
The Stytch Ruby gem makes it easy to use the Stytch user infrastructure API in Ruby applications.
It pairs well with the Stytch Web SDK or your own custom authentication flow.
Add this line to your application's Gemfile:
And then execute:
$ bundle install
Or install it yourself as:
$ gem install stytch
You can find your API credentials in the Stytch Dashboard.
This client library supports all of Stytch's live products:
- Email Magic Links
- Embeddable Magic Links
- OAuth logins
- SMS passcodes
- WhatsApp passcodes
- Email passcodes
- Session Management (Beta)
- WebAuthn (Beta)
Create an API client:
client = Stytch::Client.new( env: :test, # available environments are :test and :live project_id: "***", secret: "***" )
Send a magic link by email:
client.magic_links.email.login_or_create( email: "email@example.com", login_magic_link_url: "https://example.com/login", signup_magic_link_url: "https://example.com/signup", )
Authenticate the token from the magic link:
client.magic_links.authenticate( token: "DOYoip3rvIMMW5lgItikFK-Ak1CfMsgjuiCyI7uuU94=", )
When possible the response will contain an
error_type and an
error_message that can be used to distinguish errors.
Learn more about errors in the docs.
See example requests and responses for all the endpoints in the Stytch API Reference.
If you've found a bug, open an issue!
If you've found a security vulnerability, please follow our responsible disclosure instructions.
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Stytch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.