Is there a way to programmatically get the email verification token?

I'm writing end to end tests in cypress. I sign a user up and I want to get the verification token so that I can manually verify their email address. Or, ideally I could get the full email link so that I could visit it from my cypress test to exhaust the whole flow
4 Replies
Justin Schoen
Justin SchoenOP3mo ago
@Better Auth
Better Auth
Better Auth3mo ago
Hi there! I've noticed a few common questions in our community regarding Better Auth, especially around setting up and fine-tuning Discord as a social provider. Here are some aggregated points that might help: 1. Discord OAuth Setup:
Many ask about how to properly configure Discord login. For local development, make sure your redirect URL is set to something like
http://localhost:3000/api/auth/callback/discord (see Document 1). In production, update it to your live domain. Also, remember to import and pass the Discord social provider configuration to your auth instance. 2. Adding Bot Permissions:
Some users are looking to extend Discord integration with bot permissions during OAuth. Recent enhancements in Better Auth now allow specifying a permissions property when using the Discord provider (Document 2). This means you can pass additional Discord Bot permissions directly in the OAuth flow if your integration requires it. 3. Email Scope Concerns:
There’s been discussion about collecting the user’s email due to privacy concerns. One community request even suggested using the Discord user ID (a snowflake) in place of an email (Document 3). This approach helps maintain user privacy while still leveraging Discord for authentication. 4. Consent and Prompt Behavior:
Another popular topic is the user experience of the authorization prompt. By default, Discord may force a consent screen on every login. There have been suggestions—to default the prompt parameter to "none" when appropriate—to reduce unnecessary reauthorization (Document 13). This can streamline the login process for returning users. If you have more specific questions or need help with advanced configurations, feel free to ask. We're here to help you get the most out of Better Auth! Let me know if there’s anything else I can clear up for you.
Justin Schoen
Justin SchoenOP3mo ago
@Better Auth is there a way to get the email verification link that was sent to a user? or at least get the token?
Better Auth
Better Auth3mo ago
By default, Better Auth doesn't provide an API endpoint to retrieve the email verification link or its token once it’s sent. This is mainly for security reasons—to keep the token confidential and prevent any accidental leakage. If you need access to the verification token or link (for example, for development or debugging purposes), you can capture it inside your custom sendVerificationEmail callback. In your configuration, you have full control over the email sending logic and therefore can log or store the token and URL as needed [3], [4]. Just be cautious when handling such data, as exposing it publicly can pose security risks. Sources: 3. Email & Password | Better Auth 4. Email | Better Auth
Email & Password | Better Auth
Implementing email and password authentication with Better Auth.
Email | Better Auth
Learn how to use email with Better Auth.

Did you find this page helpful?