Authorization Server

What it is

The Authorization Server (https://auth.3b4sf.com) is where an org is connected to the 3B platform services. Once an admin has onboarded an org, the PDF Engine and Large Files Service can act on that org when called with a valid 3B sessionKey for it.

An org is onboarded once: an admin completes the onboarding form and approves an OAuth connection as an integration user. After that, no further action is needed until the authorization is revoked or the OAuth app changes.

Routes

Route Purpose
GET / The onboarding form (the "index page").
GET /addClient Submitted by the onboarding form. Redirects to Salesforce to authorize.
GET /oauth/callback Salesforce redirects back here after the integration user approves access.
GET /getToken?sessionKey=<sessionKey> Used by the 3B services to obtain access for an onboarded org.
GET /health Health check.

A successful getToken response:

{
    "success": true,
    "responseObject": {
        "sessionId": "<access-token>",
        "expiresIn": 3600,
        "instanceUrl": "https://<your-domain>.my.salesforce.com"
    }
}

Onboarding a new client

Onboarding is two stages: create an OAuth app in Salesforce, then complete the 3B onboarding form.

Stage 1: create the OAuth app in Salesforce

You need an External Client App or a classic Connected App. Either works. One app usually already exists per 3B product; only create a new one if there isn't one.

  1. In the org, go to Setup > App Manager (External Client Apps) > New External Client App, or Setup > App Manager > New Connected App on older orgs.
  2. Give it a name, for example 3B Authorization.
  3. Enable OAuth Settings and set:
    • Callback URL: https://auth.3b4sf.com/oauth/callback
    • OAuth scopes:
      • Manage user data via APIs (api)
      • Perform requests at any time (refresh_token, offline_access) (required)
    • Enable refresh token / offline access.
  4. Save. In Setup > App Manager, open the app's Manage Consumer Details to copy the Consumer Key (client id) and Consumer Secret (client secret).
  5. If prompted, set the app's refresh token policy to "Refresh token is valid until revoked" so the connection does not expire on a rolling window.

Note on External Client Apps: enable the app's OAuth flow for the Authorization Code and Refresh Token grant types, and make sure it is enabled and installed in the org before onboarding.

Stage 2: complete the 3B onboarding form (the index page)

Collect four values first:

Field Where to find it
Org ID Setup > Company Information (the 15 or 18 character org id).
Org My Domain Setup > My Domain: the full login URL, for example https://<your-domain>.my.salesforce.com.
Client ID (Consumer Key) The External Client App or Connected App from Stage 1.
Client Secret The same app.

Then:

  1. Open https://auth.3b4sf.com/.
  2. Fill in Org ID, Org My Domain, Client ID and Client Secret.
  3. Click Authorize. You are redirected to the org's Salesforce login and approval page.
  4. Log in as an integration user in that org and approve access.
  5. Salesforce redirects back and you see "Authorized successfully! You may now close this page."

The org is now onboarded. Service calls with a valid sessionKey for that org will succeed.

The user who approves in step 4 determines the permissions the 3B services act with. Approve as a dedicated integration user with the access the 3B apps need.

Supported org types

Enter the org's own My Domain URL and onboarding works with any org type:

Onboard each org separately, with its own domain and its own OAuth app.

Re-authorizing a client

Re-authorize when the authorization has been revoked, the OAuth app's secret was rotated, the integration user changed, or a service returns "not onboarded" for an org you know was set up.

  1. Open https://auth.3b4sf.com/.
  2. Enter the same Org ID plus the current My Domain, Client ID and Client Secret (update these if the app or secret changed).
  3. Click Authorize and approve in Salesforce again.

Frequently asked questions

How long is a sessionKey valid? It is time-limited. When it expires, services return "Invalid or expired sessionKey" and the page must fetch a new one.

Do callers manage the Salesforce token lifecycle? No. The 3B services handle Salesforce access for the onboarded org.

Do I need to onboard sandbox and production separately? Yes. Each org (by Org ID and My Domain) is onboarded independently, typically with its own OAuth app.

Does onboarding store our password? No. Onboarding uses an OAuth grant approved by your integration user. No username or password is collected.

One OAuth app per org or per product? A Connected App or External Client App typically already exists per 3B product; reuse it. Create a new one only if none exists or you need to isolate a client.

Which user should approve the OAuth prompt? A dedicated integration user with the access the 3B apps require. The services act with that user's permissions.

Common errors

Message Cause Fix
Missing orgId, clientId, clientSecret A form field was left blank. Fill in all four fields.
Org not found [<id>]. Start the workflow again The approval step was reached without completing the form first, or with a different Org ID. Restart from https://auth.3b4sf.com/.
Failed to obtain oAuth2 token. … (redirect_uri_mismatch) The app's callback URL isn't exactly https://auth.3b4sf.com/oauth/callback. Fix the callback URL on the External Client App or Connected App.
Failed to obtain oAuth2 token. … (invalid_client_id / invalid_client) Wrong Consumer Key or Secret, or the app isn't fully propagated yet. Re-copy the consumer key and secret; wait a few minutes after creating the app.
Failed to obtain oAuth2 token. … (invalid_grant) Wrong My Domain host, or the approval took too long. Confirm the My Domain URL and re-run the flow promptly.
Missing sessionKey parameter The call was made without a sessionKey. Ensure the caller passes the sessionKey.
Invalid or expired sessionKey The sessionKey is invalid or expired. Fetch a fresh sessionKey from the page and retry.
Org with id <id> not onboarded. The org was never onboarded, or its authorization was revoked. Re-authorize the org.
Failed to refresh oAuth2 token. … (invalid_grant) The authorization was revoked (password reset, app uninstalled, admin revoke). Re-authorize the org.