OAuth providers#
scute.signInWithOAuthProvider("google"); // sets window.location.hrefconst url = scute.getOAuthUrl("github"); // or build the URL yourselfThe URL is https://api.scute.io/v1/auth/<appId>/oauth/authorize?provider=<name>. The providers turned on for the app are in (await scute.getAppData()).data.oauth_providers ({ provider, name, icon, color? }).
After the provider, the browser lands on the app's callback URL with sct_oauth. Finish there like a magic link:
if (scute.getMagicLinkToken()) { await scute.signInWithMagicLink(); // reads sct_oauth too}SAML discovery#
const sso = await scute.discoverSSO("ada@acme.com");if (sso) { // sso: { workspace_id, saml_login_url, enforce_sso } window.location.assign(sso.saml_login_url);}discoverSSO(email) returns null when the domain has no verified, enabled SAML setup, and for any error. A URL that is not http(s) also counts as no match.
To start SP-initiated SAML for the app without discovery:
scute.signInWithSAML(); // redirectsconst url = scute.getSamlLoginUrl(); // https://api.scute.io/v1/auth/<appId>/saml/loginThe relayState argument of both is ignored by the API: after the identity provider, the user lands on the app's login URL with sct_oauth.
SSO required#
When the workspace enforces SAML for an email's domain, sign-in calls return SsoRequiredError (HTTP 403, sso_required):
import { isSsoRequiredError } from "@scute/js-core";const { error } = await scute.signInOrUp(email);if (isSsoRequiredError(error)) { if (error.ssoLoginUrl) window.location.assign(error.ssoLoginUrl); else scute.signInWithSAML();}error.ssoLoginUrl is set only when it is an http(s) URL. error.domain is the email domain.
Microsoft Authenticator#
Push sign-in with number matching, for users whose workspace has Microsoft Authenticator set up and who have the app registered. Others get HTTP 400.
const { data, error } = await scute.startMsAuthenticatorLogin("ada@acme.com");if (error) throw error;const token = data.challenge.token;// Poll until the user approves on the phone.for (;;) { const { data: status } = await scute.getChallengeStatus(token); const challenge = status?.challenge; // Show challenge.metadata.number for the user to match, when present. if (challenge?.status === "completed") break; await new Promise((r) => setTimeout(r, 2000));}const result = await scute.claimMsAuthenticatorSession(token);// { data: null, error: null } when signed in, or { data: step } for MFA or a contactclaimMsAuthenticatorSession works once per challenge: a second call returns HTTP 409.