Ruby guide
This page walks through the whole Ruby SDK in the order you would use it. Each step starts with the shortest code that works, then shows the other ways to write it.
Download the Ruby SDK if you have not done so yet.
Requirements
Ed25519 uses OpenSSL when your Ruby supports it, and a built-in implementation otherwise, so older Ruby builds work without extra setup. On Linux and macOS, pass your own system_id and storage when you create the client, as shown in Options.
Add the SDK to your project
Unzip the download into a folder in your project, for example authlyx, and require it:
With Bundler, point your Gemfile at the folder instead and require "authlyx":
Create the client
The first value is your app’s AppKey. Find it in the dashboard under your application’s credentials. The second is the version of the program you are building. AuthlyX compares it with the versions you allow in the dashboard, so raise it each time you ship a new build. See Allowed Versions.
Create one client for the whole program and call app.close when it exits.
Two ways to call the SDK
Plain calls
Without a block, a call waits for the reply and returns a Result. init always returns one, even without internet. Other calls raise AuthlyX::Error when AuthlyX refuses or cannot be reached:
Blocks
With a block, the call runs on its own thread and the block receives the Result. A failure arrives as a failed Result instead of an exception:
Use blocks in a GUI so the window keeps responding. Calls are processed one at a time, so you can make them from any thread.
Start the SDK
init connects to AuthlyX, checks that this version is allowed and loads your app’s settings. It must succeed before anything else.
Sign in
These are three ways to sign in. Use the one that matches the access type you created in the dashboard. license_login is the same as login with one value. Device login signs in the current Windows user with no form, and only works for devices you approved first; see Device login.
Create an account, change the password, add time
register_user creates the account with a license and signs it in. redeem_license adds a license’s time to the signed-in account.
Read the account
Read fields by name or with []. user_data is empty until someone signs in, and user_data.to_h returns every field. userData is the same method. The fields are listed in User Data.
Features and metadata
Features come from the plan and the account. Some are on/off, some carry a value such as "high" or 90. Metadata is extra information attached to accounts. See Features and metadata.
get_features lists every feature and get_feature returns one. For metadata, use get_all_metadata, get_metadata and check_metadata.
Save metadata
The value can be text, a number, a boolean, an array or a hash.
Cloud variables
For get_variable, data is the value itself. See Cloud variables.
Scripts
The second value is an optional revision. The SDK checks the script’s signature before returning it. It does not run the script. See Scripts.
Logs and webhooks
Staying signed in
After sign-in the SDK checks in with AuthlyX on a background thread (a heartbeat) at the interval the server sets, and refreshes features and metadata each time. If you ban, pause or expire the account, the next heartbeat ends the session.
To be told when the session ends or the connection changes, pass procs when you create the client:
on_connection receives online, disconnected, untrusted or disposed. Both can run on the background thread, so keep them short. To check right away, call app.check_session; app.on_resume does the same and is meant for when your app wakes from sleep. To run the heartbeat yourself, pass heartbeat: :manual and call check_session from your own timer. More in Sessions and heartbeats.
Offline access
Later, without internet, init succeeds with OFFLINE_MODE, and the user signs in with the same license key or username and password. The SDK checks them against the saved permit and the sign-in succeeds with the code OFFLINE_ACCESS. app.offline_access? tells you whether this PC has a valid saved permit. Signing out deletes it. See Offline access.
Updates
When this version is not allowed, init fails with UPDATE_REQUIRED or VERSION_MISMATCH and the SDK shows a Windows message box with the new version, release notes and a button to open your download page. To show your own window, pass update_prompt: false and read the details:
See Automatic updates.
Sign out and shut down
logout ends the session, clears user_data and deletes saved offline access on this PC. close stops the background work; call it when your program exits. A closed client cannot be used again.
Results and errors
AuthlyX::Error has code, message, kind, status, request_id and data. kind is server, network, security or storage. network means the SDK could not reach AuthlyX or confirm the answer; do not treat it as a ban. All codes are listed in Errors.
Options
Options are keyword arguments. Every option is optional on Windows.
On Linux, for example:
FileStore writes files readable only by the current user. MemoryStore keeps nothing after the process ends. You can also pass any object with load, save and delete methods.
A complete program
The example on GitHub is a fuller console app with a menu for every feature. Each method also has its own page with every language side by side under SDK methods.

