LexOpti is an OAuth 2.1 authorization server. Your application acts for one member in one organization: the member chooses the organization while authorizing, and every token is bound to it. To connect a member step by step, follow build a complete integration.
GET https://app.lexopti.com/api/auth/oauth2/authorize
Token
POST https://app.lexopti.com/api/auth/oauth2/token
Revocation (RFC 7009)
POST https://app.lexopti.com/api/auth/oauth2/revoke, with token and token_type_hint
API resource
https://app.lexopti.com/v1
A web application’s client is confidential: it authenticates at the token and revocation endpoints with HTTP Basic (client_secret_basic, id and secret form-encoded). A mobile or desktop app is registered as a native app, a public client without a secret that sends its client_id in the form (mobile and native apps).
Authorization code with PKCE (S256, always required). Request the resource https://app.lexopti.com/v1 at the authorization and at the token endpoint. A web application’s redirect URIs are exact HTTPS URLs, no wildcard; a native app’s are a loopback IP literal on any port, a reverse-domain private-use scheme or a claimed HTTPS URI (register a native app).
LexOpti’s sign-in page offers No account yet? Create one below its form, and an e-mail address LexOpti does not know leads there too. The member follows LexOpti’s normal sign-up: profession, organization, offer or free trial, payment when needed, and the code sent to their e-mail. The page tells them that if their organization already uses LexOpti, they should ask their manager for an invitation rather than create a second one.
Your authorization request is kept for 45 minutes, in that browser only. Once the sign-up is done, or the invitation accepted, the member goes on with it (the organization choice when they have several, then the consent) and comes back to your redirect_uri with the code and your state, as after a sign-in. Nothing changes on your side: the same request, the same callback, the same state check. Past 45 minutes, or in another browser, the account is still created but the member stays in LexOpti: they start the connection again from your software.
An application still limited to sandboxes stays so: a new member’s organization is a real one, which it cannot be authorized for.
Once an organization has installed your application for all its members, it may let your software act for the members it enrolled without their own sign-in: the delegated mode, on by default for an installed application, which the organization asks LexOpti to switch off or on. Your software then keeps one connection, an owner’s or admin’s, and names the acting member on each request with the header X-LexOpti-Acting-User: <member_id>. LexOpti runs the request with that member’s role and records, on every trail, that the identity was asserted by your application. Enrolment, the two modes and their refusals: enrol your members.
Access tokens live 15 minutes. Refresh them automatically, before they expire or when you get a 401: with the SDK, accessToken is a function called once per operation, which returns a valid token and refreshes it when needed.
Refresh tokens live 30 days and rotate at every use: each refresh returns a new refresh token, valid 30 days from then. Concurrent refreshes within 10 seconds are tolerated (the same response is returned); replaying an old refresh token later is treated as theft and revokes the whole family: store the new refresh token atomically.
An application left unused for 30 days, its last refresh token expired, needs a new authorization from the member: send them through the authorization flow again.
A refresh token is also revoked, whatever its expiry, when access ends (below): the member leaves the organization or is banned, the organization blocks your application, LexOpti disables it, the member withdraws their consent, or a replayed refresh token revoked its family.
Your client secret is shown once and stored hashed. Ask LexOpti to rotate it: the new secret is shown once, and the previous one keeps working for 24 hours, so deploy the new one within that window, without downtime.
A refresh at the token endpoint, with HTTP Basic: store the new refresh token before you use the access token.
A Headers object, an object literal, or an array of two-item arrays to set request's headers.
headers: {
authorization: string
authorization: `Basic ${
const basic:string
basic}` },
RequestInit.method?: string |undefined
A string to set request's method.
method: "POST",
}
);
if (!
const response:Response
response.
Response.ok: boolean
The ok read-only property of the Response interface contains a Boolean stating whether the response was successful (status in the range 200-299) or not.
When the member disconnects LexOpti in your software, revoke their tokens at the revocation endpoint with HTTP Basic: first the refresh token, which ends the grant, then the access token. Drop the tokens even if a revocation fails.
Every request re-checks that the member still belongs to the organization, is not banned, that the organization has not blocked your application, that LexOpti has not disabled it, and that the member’s consent still exists. Any of these gone: the next request answers 401 invalid_token, whatever the token’s expiry. A token never acts beyond the member’s current consent: a consent narrowed to fewer scopes narrows the tokens already issued.
Test Request in the API reference and the live preview of the playground sign you in with the portal’s own application, for one of your sandboxes only, and keep the token in the page’s memory, never in the browser’s storage. The playground opens the authorization in a window; when the browser blocks it, when it is closed without an answer or takes too long, or when you choose Open in this tab, it continues in the same tab and brings you back to the playground with its settings. The API reference can only use a window, as its viewer offers no other way: if your browser blocks it, allow pop-ups for the portal, or paste an access token under Authentication.