API_BASE_URL is the externally reachable address of the FIM One backend. Examples:
GitHub
Developer console: https://github.com/settings/developers- Click OAuth Apps → New OAuth App.
- Fill in:
- Application name — any name (e.g.
FIM One) - Homepage URL — your frontend URL (e.g.
https://yourdomain.com) - Authorization callback URL —
https://yourdomain.com/api/auth/oauth/github/callback
- Application name — any name (e.g.
- Click Register application, then click Generate a new client secret.
- Copy the Client ID and the generated Client Secret into your
.env.
read:user, user:email
GitHub accounts with a private primary email are handled correctly — FIM One fetches the primary email from /user/emails (not the public profile email) and records whether GitHub marks it verified.
- Click + CREATE CREDENTIALS → OAuth client ID.
- If prompted, configure the OAuth consent screen first (set User Type to “External” for personal/public apps).
- Set Application type to Web application.
- Under Authorized redirect URIs, add:
- Click Create, then copy the Client ID and Client Secret.
openid, email, profile
Note: During development the consent screen will show a “This app is not verified” warning. You can proceed past it for testing. Publish the consent screen if you want to remove the warning for end users.
Discord
Developer console: https://discord.com/developers/applications- Click New Application and give it a name.
- In the left sidebar, click OAuth2.
- Under Redirects, click Add Redirect and enter:
- Copy the Client ID (shown at the top of the OAuth2 page) and click Reset Secret to reveal the Client Secret.
identify, email
Discord does not guarantee a verified email for all accounts. If a user has not verified their email with Discord, thenull. FIM One creates the account with a null email in that case — the user can add one later in Settings.
Feishu (Lark)
Developer console: https://open.feishu.cn/app- Click Create App → In-house app (自建应用). Company/enterprise accounts are required — Feishu OAuth is not available for personal accounts.
- Under Permissions & Scopes, search for and enable:
contact:user.email:readonly
- Under Security Settings → Redirect URL, add your callback URL:
- Copy the App ID and App Secret from the Credentials & Basic Info section.
contact:user.email:readonly
Note: Feishu usesApp ID/App Secretinstead of the standardClient ID/Client Secretnaming. The env var names reflect this:FEISHU_APP_IDandFEISHU_APP_SECRET.
Important: Feishu Email Behavior
The Feishu user info API (authen/v1/user_info) returns an email and an enterprise contact email (联系邮箱, enterprise_email) — the address configured by the organization admin in the Feishu admin console. FIM One reads email first, then enterprise_email. The address counts as verified only when it is the enterprise email of a tenant listed in FEISHU_TRUSTED_TENANT_KEYS.
Consequences:
- Users whose org admin has not configured a contact email will get an empty email field from the API, even though they have a valid Feishu account.
- Users on personal Feishu accounts (not part of an enterprise) will always get an empty email.
Account Binding Rules
Registered users can link additional OAuth providers from Settings → Account. The following rules apply when a user initiates a binding:Linking from Settings (all providers)
Linking needs a full sign-in: a session that has passed two-factor authentication where it is enabled. API keys and the temporary 2FA token cannot link a provider.- Both sides have an email → the email returned by the provider must match the FIM account’s email. This prevents accidentally linking another person’s social account to your FIM account. A mismatch is rejected with an
email_mismatcherror. - Either side has no email (the provider returned none, or the FIM account has no email) → binding succeeds on the signed-in session alone. In practice this affects Feishu accounts without an enterprise email and some Discord accounts.
First sign-in with a provider (no binding yet)
When a user signs in through a provider that is not linked to any account yet:- FIM One looks for an existing account with the same email. The match is used only when the address is verified on both sides: the provider reports it as verified, and the existing account’s email is verified. For Feishu, “verified” means the enterprise email of a tenant listed in
FEISHU_TRUSTED_TENANT_KEYS. - If a match is found, the provider is linked to that existing FIM account and the user is logged in.
- Otherwise a new FIM account is created with whatever email the provider returned (none, if it returned none). This is refused with
registration_disabledwhen registration is disabled or invite-only.
email_verification_enabled on and SMTP configured), when an administrator created it, when it is the first account of the installation, or when it was created by a provider sign-in whose provider reported the address as verified. An account registered with an email and a password on a deployment that does not send verification codes holds an unverified address: a provider sign-in for that address is not linked to it and creates a separate account instead, so two accounts can then hold the same address. A password signs in to the account it was set on; an emailed sign-in or reset code goes to the account whose address is verified. To use one account with both, sign in with the password first and link the provider under Settings → Account, instead of using the provider’s button on the sign-in page.
If the matched or linked account has two-factor authentication enabled, the sign-in stops at the 2FA step before a session is issued.
Environment Variables Quick Reference
“Required: Both” means both the
_ID and _SECRET (or _APP_ID and _APP_SECRET for Feishu) must be set together; setting only one has no effect.
See Environment Variables for full documentation ofFRONTEND_URL,API_BASE_URL, andNEXT_PUBLIC_API_URL.