OIDC Plugin data migration
I have in my database the ids of the users from my previous authentication provider. I want to migrate these users to a my new better-auth backend so I can handle this data there. I've added a button where they can link the account and this is working perfectly.
However, I wonder if I can migrate the users from the old to the new app, just with the users ids. I saw that in the tables better-auth saves some tokens, but not the id directly. So I would like to know if there's a way to do this migration, without the users to manually connecting their accounts again. Thanks for the help.
5 Replies
@Better Auth
Hi there! Here are some common Better Auth questions from our Discord community along with best-practice answers:
1. How do I configure the Discord provider?
To use Discord sign‐in you need to set your client ID, secret, and the correct redirect URL. For local development use the default URL (http://localhost:3000/api/auth/callback/discord) and update it in production if needed [2]. You can also enable advanced features such as passing bot permissions during the OAuth flow by supplying an optional “permissions” parameter when using the bot scope [1]. 2. Why does Discord always prompt for authorization?
If you notice that users are repeatedly asked for consent, it may be because the default prompt parameter is set to “consent.” You can change this behavior by setting the prompt to “none” so that, after the first authorization, users aren’t forced to re-consent [14]. There’s also been work to add a consent option which you might find useful [3]. 3. What about email privacy concerns with Discord sign in?
Some users are worried about their real email addresses being collected. There have been proposals to offer a configuration field that lets developers replace the real email with a dummy one for enhanced privacy. This lets users know exactly which scope is granting access to their email and gives you the flexibility to adjust the behavior [4][5]. 4. How can I keep user profile data up-to-date?
If you need to update profile pictures (or other profile details) on every login—for instance, if a user
To use Discord sign‐in you need to set your client ID, secret, and the correct redirect URL. For local development use the default URL (http://localhost:3000/api/auth/callback/discord) and update it in production if needed [2]. You can also enable advanced features such as passing bot permissions during the OAuth flow by supplying an optional “permissions” parameter when using the bot scope [1]. 2. Why does Discord always prompt for authorization?
If you notice that users are repeatedly asked for consent, it may be because the default prompt parameter is set to “consent.” You can change this behavior by setting the prompt to “none” so that, after the first authorization, users aren’t forced to re-consent [14]. There’s also been work to add a consent option which you might find useful [3]. 3. What about email privacy concerns with Discord sign in?
Some users are worried about their real email addresses being collected. There have been proposals to offer a configuration field that lets developers replace the real email with a dummy one for enhanced privacy. This lets users know exactly which scope is granting access to their email and gives you the flexibility to adjust the behavior [4][5]. 4. How can I keep user profile data up-to-date?
If you need to update profile pictures (or other profile details) on every login—for instance, if a user
GitHub
Build software better, together
GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.

GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
GitHub
Build software better, together
GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.

changes their Discord avatar—you can use profile hooks in your Discord provider configuration. These hooks can help you compare and update details like the image URL during sign-in [20] and address issues where cached information might become outdated [18].
5. Advanced provider configuration and refresh tokens:
For providers like Google and Discord, ensure you’ve set the required scopes (like “identify” and “email”) during initialization. Note that while the Google provider’s refresh token behavior has been a topic of discussion and improvement [32], Discord provider updates (including bot permissions and consent prompt adjustments) are continuously evolving for better integration [1][14]. These aggregated answers reflect both best practices and several community-sourced suggestions. If you have further questions or need more examples, feel free to ask!
For providers like Google and Discord, ensure you’ve set the required scopes (like “identify” and “email”) during initialization. Note that while the Google provider’s refresh token behavior has been a topic of discussion and improvement [32], Discord provider updates (including bot permissions and consent prompt adjustments) are continuously evolving for better integration [1][14]. These aggregated answers reflect both best practices and several community-sourced suggestions. If you have further questions or need more examples, feel free to ask!
GitHub
Feat: Profile Hooks · Issue #950 · better-auth/better-auth
Is this suited for github? Yes, this is suited for github Is your feature request related to a problem? Please describe. It currently seems impossible to update User values based on their linked so...
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
GitHub
better-auth/better-auth
The most comprehensive authentication framework for TypeScript - better-auth/better-auth
Sources:
[1] feat: add Discord bot permissions parameter support
[2] Discord | Better Auth
[3] feat(discord): add consent as an option
[4] feat: Discord Oauth without the email scope
[5] feat:Add Discord OAuth email scope configuration field
[14] Discord login always prompts for authorization
[18] Updating Discord image everytime the user logs in.
[20] Feat: Profile Hooks
[32] Google Provider refresh token
GitHub
feat: add Discord bot permissions parameter support by TheUntraceab...
When using the Discord social plugin, you can set the bot scope, and this scope can have an additional permissions scope, referring to the permissions of the Discord Bot once authorized.
This pull ...
Discord | Better Auth
Discord provider setup and usage.
GitHub
feat(discord): add consent as an option by Bekacru · Pull Request ...
closes #739
adds a consent option to Discord, defaulting to none as suggested in the linked issue.
GitHub
feat: Discord Oauth without the email scope · Issue #2059 · bette...
Is this suited for github? Yes, this is suited for github Is your feature request related to a problem? Please describe. I find collecting email addresses a potential privacy concern depending on t...
GitHub
feat:Add Discord OAuth email scope configuration field by Summerlyt...
Collecting the real email address is a privacy concern. By implementing this simple fix, it allows users to replace said address with a dummy address easily. I understand you can write over the ema...
It's a custom provider using the genericOAuth plugin @Better Auth