Skip to content

authsignal/authsignal-ruby

Repository files navigation

Authsignal

Authsignal Ruby SDK

The Authsignal Ruby library for server-side applications.

Installation

Add this line to your application's Gemfile:

gem "authsignal-ruby"

Documentation

Refer to our SDK documentation for information on how to use this SDK.

Or check out our Ruby on Rails Quickstart Guide.

Response & Error handling

The Authsignal SDK offers two response formats. By default, its methods return the payload in hash format.

Example:

Authsignal.enroll_verified_authenticator(
  user_id: 'AS_001',
  attributes: {
    verification_method: 'INVALID',
    email: '[email protected]'
  }
)

# returns:
{
  "error": "invalid_request",
  "errorCode": "invalid_request",
  "errorDescription": "body.verificationMethod must be equal to one of the allowed values - allowedValues: AUTHENTICATOR_APP,EMAIL_MAGIC_LINK,EMAIL_OTP,SMS"
}

All methods have a bang (!) counterpart that raises an Authsignal::ApiError if the request fails.

Example:

Authsignal.enroll_verified_authenticator!(
  user_id: 'AS_001',
  attributes: {
    verification_method: 'INVALID',
    email: '[email protected]'
  }
)

# raise:
<Authsignal::ApiError: AuthsignalError: 400 - body.verificationMethod must be equal to one of the allowed values - allowedValues: AUTHENTICATOR_APP,EMAIL_MAGIC_LINK,EMAIL_OTP,SMS.