The first two are served by
https://crm.lofty.com/api/user-web/oauth/token; Client Credentials is served by https://api.lofty.com/oauth/token. They differ in more than the host — see Choosing between them.Prerequisites
You need a Developer Platform account and a registered application. Sign up at the Lofty Developer Portal.Authorization Code flow
1
Register your application
Create a new application in the Developer Portal. Provide your app name, description, and redirect URI(s).New applications start in Development Mode — you can test the full OAuth flow without review.
2
Obtain credentials
After registration, you’ll receive a Client ID and Client Secret.
3
Request an access token
Exchange your credentials for an access token via the OAuth 2.0 authorization code flow.The
Authorization header uses HTTP Basic authentication: Base64-encode <CLIENT_ID>:<CLIENT_SECRET> to produce the credential string.For complete token endpoint details, see the OAuth 2.0 API Reference.4
Authenticate requests
Pass the access token in the
Authorization header:PKCE flow
Use PKCE (RFC 7636) for public clients: SPAs, desktop apps, and command-line tools that cannot keep a client secret. A one-time code verifier proves that the app redeeming the code is the app that started the login.If your app runs on a server and can keep its client secret, use the Authorization Code flow with the
Authorization: Basic header instead. You can send PKCE parameters with it as well.1
Create a code verifier and challenge
For every login, generate a random Lofty accepts only the
code_verifier (43–128 characters from A-Z a-z 0-9 - . _ ~) and a random state. Keep both in memory. Derive the challenge from the verifier:S256 method.2
Send the user to the authorization page
Open this URL in the user’s browser. It is split across lines here for readability; send it as one URL with each value URL-encoded:After the user approves, the browser is redirected to
redirect_uri with code and state in the query string. If the user denies access, it is redirected there with error=access_denied instead. Check that state matches the value you sent before you use the code.3
Exchange the code for tokens
redirect_uri you used in the authorization request. No client_secret is sent.Redirect URIs for desktop and command-line apps
The authorization code reaches your app only through the registeredredirect_uri. There is no other endpoint that returns it. A native app receives it on a loopback address (RFC 8252):
- Listen on
127.0.0.1and usehttp://127.0.0.1:<PORT>/callbackas theredirect_uri. - Lofty compares redirect URIs exactly, including the port. Register every port your app may use in the Developer Portal. There is no wildcard port.
- Pick a few fixed, uncommon ports and try them in order. An app can register at most five redirect URIs, so keep the list short. If none is free, or the browser runs on another machine (for example over SSH), let the user paste the callback URL from the browser’s address bar into your app.
lofty-cli auth login-browser listens on the first free port of its registered set and falls back to a pasted callback URL. See CLI troubleshooting.
Refresh an access token
Access tokens from the Authorization Code and PKCE flows last 10 days. Exchange the refresh token for a new pair before the access token expires — the user does not need to sign in again.Authorization header and send -d "client_id=<CLIENT_ID>" instead. Use the same client ID the user authorized.
A successful response:
- The refresh token lasts 180 days, counted from the last refresh. Each refresh starts a new 180 days. Refresh at least once every 180 days and the user never has to re-authorize.
- Refresh keeps the scopes the user approved. It does not add scopes your app gained afterwards — see Permission scopes.
- When to refresh: track
expires_inand refresh before it runs out. If a call is rejected because of its credentials, refresh once and retry the call. If the refresh itself fails, send the user through authorization again.
error field instead of tokens — for example "error": "invalid_request" with "error_description": "refresh token not found". Check the body for error; do not rely on the HTTP status alone.
Revoked access
When a user disconnects your app, Lofty deletes the tokens for that user and your app. When your app is deactivated, Lofty deletes all of its tokens. Calls and refreshes with those tokens fail, and the user has to authorize your app again.Client Credentials flow
For server-to-server integrations where there is no browser to send a user to. Instead of a user approving your app, the account holder creates an API Key in their Lofty CRM (Settings → Integrations → API Keys) and gives it to you. You exchange it, together with your app credentials, for a short-lived access token.
A successful response:
oat_, lasts 2 hours, and carries no refresh token — mint a new one when it expires. Send it as Authorization: Bearer <ACCESS_TOKEN>, the same as any other access token.
Choosing between them
Permission scopes
Calling an endpoint a token is not scoped for returnsHTTP 403. The body differs by grant type, because the two are checked against different records:
App lifecycle
Updating a production app
Once in production, edits require review before taking effect. Your app continues operating with the current approved configuration during review. Non-breaking changes — app name, description, redirect URIs. Existing connections are unaffected. Adding scopes — existing connections keep working with the scopes they have. Only users who authorize your app again get the new scopes. Notify users before you submit, so they know to re-authorize. Removing scopes — applies to every existing connection once the edit is published. Calls to the removed endpoints return403.
Can I edit while a review is pending?
Can I edit while a review is pending?
No. Edit controls are locked during review. Cancel the pending edit first if you need to make urgent changes.
What happens if my edit is declined?
What happens if my edit is declined?
Your app continues operating with its current configuration. You’ll receive the decline reason via email and can resubmit after making adjustments.