Hey folks, trying to setup password verify/reset emails using resend as described by the docs here: https://labs.convex.dev/auth/config/passwords#email-verification-setup
I've followed the exact instructions (login was working with email/pass before I tried to add verify/reset flows) and my file looks exactly like this:
convex/ResendOTP.ts
import Resend from "@auth/core/providers/resend";
import { Resend as ResendAPI } from "resend";
import { alphabet, generateRandomString } from "oslo/crypto";
export const ResendOTP = Resend({
id: "resend-otp",
apiKey: process.env.AUTH_RESEND_KEY,
async generateVerificationToken() {
return generateRandomString(8, alphabet("0-9"));
},
async sendVerificationRequest({ identifier: email, provider, token }) {
const resend = new ResendAPI(provider.apiKey);
const { error } = await resend.emails.send({
from: "My App <[email protected]>",
to: [email],
subject: `Sign in to My App`,
text: "Your code is " + token,
});
if (error) {
throw new Error("Could not send");
}
},
});
convex/auth.ts
export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
providers: [
Password({
reset: ResendOTPPasswordReset,
verify: ResendOTP,
}),
],
...
});
Also:
- my custom domain is verified
- my api key is active and has the right perms (and shows in my logs when i dump out
provider.apiKeyso i know im getting it) - running
"resend": "^4.6.0",and"@convex-dev/auth": "^0.0.87",
But I still end up with:
[CONVEX A(auth:signIn)] [ERROR] 'Could not send verification email' {
error: 'Invalid RESEND_API_TOKEN',
...
}
Not sure how this is happening?
I've tried:
- passing the API key directly to
new ResendAPI() - ive made new API keys
- I've tried sending both from my domain and from the default resend domain
Any ideas or help is appreciated!
Authentication library for your Convex backend