Scute::Client holds the app id, the secret key and the HTTP settings. Create one and reuse it.
scute = Scute::Client.new( app_id: ENV["SCUTE_APP_ID"], secret: ENV["SCUTE_SECRET"], base_url: "https://api.scute.io", open_timeout: 5, read_timeout: 10, retries: 1)Options#
Environment variables#
| Variable | Used for | Default |
|---|---|---|
| SCUTE_APP_ID | app_id | none (required) |
| SCUTE_SECRET | secret | none |
| SCUTE_BASE_URL | base_url | https://api.scute.io |
The controller concerns and Scute::Harness create their own client with Scute::Client.new, so they read the same variables.
Which calls need the secret key#
| Call | Credential |
|---|---|
| tokens.verify (without remote: true) | none: reads the app's public JWKS |
| sessions.current_user, sessions.refresh, sessions.sign_out | the user's own token |
| tokens.verify(token, remote: true) | the user's own token |
| users.*, sessions.list, sessions.revoke | secret key |
| authz.*, agents.* | secret key |
A secret-key call without a secret raises Scute::ConfigurationError ("This call needs the app's secret key") before any request is made.
Retries#
The client retries once (retries: 1) on a network error (connection refused or reset, host unreachable, timeouts, DNS, EOFError, TLS errors) for GET requests and for calls that are safe to repeat: authz.check, authz.check_batch, authz.filter and users.update. Calls that create something (users, tasks, challenges, requests) are never retried. When the retries run out the client raises Scute::ConnectionError.
Requests#
Every request sends Accept: application/json, Content-Type: application/json and User-Agent: scute-ruby/<version>. Secret-key calls send Authorization: Bearer <secret>.
Copies and inspect#
scute.with_client_ip(ip) returns a copy of the client with another client IP. The original is unchanged.
scute.inspect shows the app id and secret="***", never the key. scute.secret? is true when a secret is set.