How to link Generic OAuth to existing user

I have a question about Generic OAuth account linking. Say I have a user fred@example.com. I set up a Generic OAuth plugin to authenticate to Nylas, which in turn sends the user through an OAuth authentication with their Google account. But say the user's Google account email is fred@gmail.com.

Currently when user completes the Nylas authentication, better-auth is creating a new user fred@gmail.com, then creating a Nylas account record linked to that new user. But I want the Nylas account record to be linked to the currently-logged-in user fred@example.com and not create a new user when the emails are different.

I tried this in my auth.ts config but it didn't help:
    account: {
        accountLinking: {
            allowDifferentEmails: true,
        },
    },
Was this page helpful?