Discord integration problems.

Hi, I’m having an issue with integrating Discord with Better-Auth. In my app, I have the following logic using authClient.linkSocial:
const handleLinkDiscord = async () => {
try {
await authClient.linkSocial({
provider: 'discord',
});
} catch (error) {
console.error('Error:', error);
}
};
const handleLinkDiscord = async () => {
try {
await authClient.linkSocial({
provider: 'discord',
});
} catch (error) {
console.error('Error:', error);
}
};
This is supposed to add an Account to the database linked to my user with Discord as the provider. The problem is that the authorization popup appears, the button at the bottom shows loading, and then literally after 2 seconds I get redirected back to my site with the URL /dashboard?discord=connected. I have all environment variables set correctly — I’ve double-checked several times. I even added allowDifferentEmails to the account config in src/lib/auth.ts, but it didn’t change anything:
account: {
accountLinking: {
enabled: true,
allowDifferentEmails: true
},
},
account: {
accountLinking: {
enabled: true,
allowDifferentEmails: true
},
},
ts
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
discord: {
clientId: process.env.DISCORD_CLIENT_ID as string,
clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
redirectURI: process.env.DISCORD_REDIRECT_URI as string,
},
},
ts
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
discord: {
clientId: process.env.DISCORD_CLIENT_ID as string,
clientSecret: process.env.DISCORD_CLIENT_SECRET as string,
redirectURI: process.env.DISCORD_REDIRECT_URI as string,
},
},
Do you have any idea what else I could try?
No description
1 Reply
Bialymodelu
BialymodeluOP3mo ago
solved!

Did you find this page helpful?