メインコンテンツへスキップ
FIM One は GitHub、Google、Discord、Feishu (Lark) 経由のソーシャルログインをサポートしています。環境に認証情報が存在するプロバイダーは、コード変更なしでサインインページにログインボタンを自動的に表示します。 コールバック URL パターン — 各プロバイダーの開発者コンソールにこの正確な URL を登録してください:
API_BASE_URL は FIM One バックエンドの外部からアクセス可能なアドレスです。例:

GitHub

Developer console: https://github.com/settings/developers
  1. Click OAuth Apps → New OAuth App.
  2. 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
  3. Click Register application, then click Generate a new client secret.
  4. Copy the Client ID and the generated Client Secret into your .env.
Scopes requested automatically: 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.

Google

デベロッパーコンソール: https://console.cloud.google.com/apis/credentials
  1. + CREATE CREDENTIALS → OAuth client ID をクリックします。
  2. プロンプトが表示された場合は、まず OAuth consent screen を設定します(個人用/公開アプリの場合、User Type を「External」に設定します)。
  3. Application type を Web application に設定します。
  4. Authorized redirect URIs に以下を追加します:
  5. Create をクリックし、Client ID と Client Secret をコピーします。
自動的にリクエストされるスコープ: openid, email, profile
注意: 開発中、consent screen に「This app is not verified」という警告が表示されます。テストのためにこれを無視して進めることができます。エンドユーザーの警告を削除したい場合は、consent screen を公開してください。

Discord

開発者コンソール: https://discord.com/developers/applications
  1. New Application をクリックして、アプリケーションに名前を付けます。
  2. 左側のサイドバーで OAuth2 をクリックします。
  3. Redirects の下で Add Redirect をクリックして、以下を入力します:
  4. Client ID(OAuth2 ページの上部に表示)をコピーし、Reset Secret をクリックして Client Secret を表示します。
自動的にリクエストされるスコープ: identify、email
Discord はすべてのアカウントに対して検証済みメールを保証していません。ユーザーが Discord でメールを検証していない場合、email フィールドは null になる可能性があります。FIM One はこの場合、null メールでアカウントを作成します。ユーザーは後で設定でメールを追加できます。

Feishu (Lark)

テナントスコープのみ。 Feishuの自建応用は、アプリを作成した同じエンタープライズテナント内のユーザーのみを認証できます。他のFeishuテナントのユーザーには「権限なし」エラーが表示されます。つまり、Feishu OAuthは異なる組織のユーザーが利用するパブリックSaaS展開には適していません。すべてのユーザーが同じFeishuテナントに属するプライベート/単一組織の展開に適しています。クロステナントのFeishuログインをサポートするには、アプリをFeishuアプリストアに公開し、Feishuのレビュープロセスに合格する必要があります。これは複雑で厳しい要件があります。
開発者コンソール: https://open.feishu.cn/app
  1. Create App → In-house app (自建応用)をクリックします。企業/エンタープライズアカウントが必要です。個人アカウントではFeishu OAuthは利用できません。
  2. Permissions & Scopesで以下を検索して有効にします:
    • contact:user.email:readonly
  3. Security Settings → Redirect URLでコールバックURLを追加します:
  4. Credentials & Basic InfoセクションからApp IDとApp Secretをコピーします。
コンソールで設定されたスコープ(認可URLではなく): contact:user.email:readonly
注: Feishuは標準的なClient ID / Client Secretの命名ではなく、App ID / App Secretを使用します。環境変数の名前はこれを反映しています: FEISHU_APP_IDとFEISHU_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.
FIM One handles this gracefully: see Account Binding Rules below.

アカウントバインディングルール

登録済みユーザーは、設定 → アカウントから追加のOAuthプロバイダーをリンクできます。ユーザーがバインディングを開始する際には、以下のルールが適用されます。

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_mismatch error.
  • 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:
  1. 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.
  2. If a match is found, the provider is linked to that existing FIM account and the user is logged in.
  3. Otherwise a new FIM account is created with whatever email the provider returned (none, if it returned none). This is refused with registration_disabled when registration is disabled or invite-only.
When is an account’s email verified? When it was registered with the emailed verification code (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 of FRONTEND_URL, API_BASE_URL, and NEXT_PUBLIC_API_URL.