DecaneDocs
UsersSign-in
Users

Server-side sign-in

The same sign-in flows the frontend SDKs offer, minus anything that needs a browser or a device authenticator. Every call needs your developer API key.

rust
let decane = DecaneClient::builder()
    .app_id(app_id)
    .api_key(std::env::var("DECANE_API_KEY")?)
    .build()?;

Email code

rust
decane.connect_with_email("user@example.com").await?;                // emails a 6-digit code
let session = decane.verify_email_code("user@example.com", "123456").await?;

Phone code

rust
decane.connect_with_phone("+2348012345678").await?;                  // E.164 only
let session = decane.verify_phone_code("+2348012345678", "123456").await?;

Token exchange

One step each, for a token the user already holds:

rust
decane.connect_with_google_token(google_id_token).await?;            // a Google ID token
decane.connect_with_kingschat_token(kc_access_token).await?;         // a KingsChat access token
decane.connect_with_token(jwt_from_your_issuer, Some("prov-1")).await?; // custom auth

The result

rust
session.access_token; // a Decane JWT (8 h): verify it, or hand it to the client
session.user_id;      // stable Decane user id
session.is_new_user;  // true on the user's first sign-in
session.has_share;    // false = no wallet yet
session.profile;      // Option<AuthProfile { name, email, picture }> for Google and KingsChat

The profile is passed through from the provider and never stored by Decane.

Sign-out

rust
decane.revoke_access_token(&session.access_token).await?;

Caveats

  • Rate limits. There is no per-IP limit on sign-in, so one server egress IP is fine. OTP attempts are limited to 10 per 15 minutes per email or phone, and code sends to 3 per hour per address.
  • Anti-enumeration. connect_with_email and connect_with_phone succeed whether or not the address is known. Never tell a user an email was not found.
  • Token renewal. Tokens last 8 hours. POST /auth/refresh with a still-valid token returns a fresh one, up to 7 days after sign-in; this crate does not wrap it yet.
  • Not available server-side: the Google redirect flow, the KingsChat popup and passkey sign-in. Signing transactions stays in the client SDKs.