Discord OAuth Setup Guide

Follow these steps to enable Discord login for your app

1
Go to Discord Developer Portal

Open your Discord application settings:

Discord Developer Portal
2
Add OAuth2 Redirect URLs (BOTH required)

Navigate to: OAuth2 → Redirects

You need two redirect URLs registered. Click "Add Redirect" for each:

① Account Linking (profile → link Discord)

https://doordiehub.com/functions/discordOAuthCallback

② Platform SSO Login — Web/Browser (desktop + mobile browser)

https://base44.app/api/apps/690788bbf9e29b9d99491d7d/auth/sso/callback

③ Platform SSO Login — Native App (iOS/Android Base44 app — REQUIRED or login fails on mobile)

https://app.base44.com/api/apps/690788bbf9e29b9d99491d7d/auth/sso/callback

CRITICAL: All Three URLs Required

The platform uses different callback domains depending on where the user starts login:
Browser (desktop + mobile browser) → uses base44.app
Native app (iOS/Android Base44 app) → uses app.base44.com
If URL ③ is missing, native app login fails with "Discord authentication failed" — the error appears on app.base44.com and the user is never redirected back into the app. This is the exact symptom of a missing app.base44.com redirect URI.

Note: After adding both, click "Save Changes" at the bottom of the page!

3
Verify SSO Secrets (Discord Login)

These sso_* secrets control the platform's Discord SSO login flow. Set them in your Base44 dashboard under Settings → Environment Variables:

sso_client_id= your Discord Client ID
sso_client_secret= your Discord Client Secret
sso_scope= identify email
sso_auth_endpoint= https://discord.com/api/oauth2/authorize
sso_token_endpoint= https://discord.com/api/oauth2/token
sso_userinfo_endpointMUST BE PROXY

Discord returns id instead of the OIDC sub field. The Base44 SSO requires sub to identify the user. Set this to the OIDC proxy function URL:

https://base44.app/api/apps/690788bbf9e29b9d99491d7d/functions/discordOIDCUserinfo

This proxy receives the Discord access token from the platform SSO, calls Discord's /users/@me, and reshapes the response to include sub, email_verified, and other OIDC fields.

Also verify: DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET, and DISCORD_REDIRECT_URI are set (used for account linking).

Test Discord Login

After completing the above steps, try these features:

  • Link Discord from your profile settings
  • Sign in with Discord button (prompts when not logged in)
  • Purchase membership (requires Discord link)
Common Issues

"Discord authentication failed" after clicking Authorize

This means the platform SSO received the Discord callback but the OAuth exchange failed. Three causes:

  • Missing app.base44.com redirect URI: The native iOS/Android app uses app.base44.com as the SSO callback domain, NOT base44.app. If only the base44.app redirect is registered (URL ②), browser login works but the native app fails. Add URL ③ (app.base44.com version) to fix native app login.
  • Missing base44.app redirect URI: Browsers use base44.app as the SSO callback domain. If only the app.base44.com redirect is registered, native app login works but browser login fails. Add URL ② to fix browser login.
  • OIDC proxy not configured: The sso_userinfo_endpoint secret doesn't point to the OIDC proxy. Set it to the proxy URL from Step 3.

"Invalid OAuth2 redirect_uri" Error

The redirect URL in Discord must EXACTLY match what's in Step 2. No trailing slashes.

404 Page Not Found

Wait 1-2 minutes after saving changes in Discord. The backend function needs to be deployed.

Login Page Doesn't Show Discord

Base44's built-in login page can't be customized. Discord login appears in-app via prompts and profile settings.