© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•14mo ago•
10 replies
Grubse

Unable+to+exchange+external+code

Help Needed with Supabase Authentication: Discord Integration Fails to Exchange Code

We’re experiencing an issue with Supabase Authentication when integrating Discord as an OAuth provider. Here’s the background:

Current Status
- Our application is live in both production and development environments.
- Google Authentication is working perfectly in both environments.

Issue
- After adding Discord as a provider, the OAuth flow does not work as expected.
- Specifically, the
code
code
parameter in the callback redirect URL is
null
null
.

Technical Details
- This is how we’re handling the code exchange on the server side:

  const code = url.searchParams.get('code'); // Returns null
  const { error } = await supabase.auth.exchangeCodeForSession(code);
  const code = url.searchParams.get('code'); // Returns null
  const { error } = await supabase.auth.exchangeCodeForSession(code);

The returned URL from Supabase looks like this:
https://ourdomain.com/login#error=server_error&error_code=unexpected_failure&error_description=Unable+to+exchange+external+code%253A+AkNWP1trHiCmeV4DhOOCpD4XBcpgEE

- From the error, it appears Supabase is unable to exchange the external code.

What We’ve Checked
- Redirect URIs are correctly configured in both Discord and Supabase.
- The Discord application is set up to match the same flow as Google Authentication (client ID, client secret, scopes, etc.).
- This issue is consistent in both development and production environments.

Questions
- Are there any known compatibility issues or additional configurations required for Discord OAuth in Supabase?
- What could be causing the code parameter to be null?
- Is there a way to debug this further, or are there specific Supabase logs we should check?

We’d greatly appreciate any guidance or suggestions to resolve this!

Thanks in advance for your help.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Unable to exchange external code
SupabaseSSupabase / help-and-questions
4y ago
Keycloak Provider - Error unable to exchange external code
SupabaseSSupabase / help-and-questions
4y ago
I am unable to call external API
SupabaseSSupabase / help-and-questions
7mo ago
connecting to external postgres db
SupabaseSSupabase / help-and-questions
4y ago