#Auth Error, No auth provider found

4 messages · Page 1 of 1 (latest)

bold falcon
#

This is what shown on my websocket

{type: "AuthError", error: "No auth provider found matching the given token", baseVersion: 0}

This is how I do the login

const { signIn } = useAuthActions();

Then

  const form = new FormData();
          form.set("email", email);
          await signIn("resend-otp", form);

and

 form.set("email", email);
          form.set("code", otp);
          try {
            const result = await signIn("resend-otp", form);
            console.log("result", result);
          } catch (error) {
            console.error(error);

and here is the backend set up

resendOtp.ts

import { Email } from "@convex-dev/auth/providers/Email";
import { alphabet, generateRandomString } from "oslo/crypto";
import { Resend as ResendAPI } from "resend";

export const ResendOtp = Email({
  id: "resend-otp",
  apiKey: process.env.AUTH_RESEND_KEY,
  maxAge: 15 * 60,
  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: "no-reply <no-reply@atthe.club>",
      to: [email],
      subject: "Your one-time password",
      text: `Your one-time password is ${token}`,
    });

    if (error) {
      throw new Error(error.message);
    }
  },
});

import { convexAuth } from "@convex-dev/auth/server";
import { ResendOtp } from "./resendOtp";

export const { auth, signIn, signOut, store } = convexAuth({
  providers: [ResendOtp],
});

autumn briarBOT
#

Hi @bold falcon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in your question and the knowledge sources available, it appears you're encountering an authentication error with Convex Auth using the ResendOTP provider. Let's analyze the possible issues:

  1. Provider Configuration:
    Your auth.ts file seems to be correctly set up with the ResendOTP provider. However, make sure that the id in your ResendOtp configuration matches the one you're using in the signIn function. In your code, you're using "resend-otp", which matches the id in your ResendOtp configuration Auth > Config > OTPs (https://labs.convex.dev/auth/config/otps#provider-configuration).

  2. Environment Variables:
    Ensure that you have correctly set up the AUTH_RESEND_KEY environment variable on your Convex backend. You can set it using the command:

npx convex env set AUTH_RESEND_KEY yourresendkey
  1. Convex Dev Server:
    Make sure you have the Convex dev server running in a separate terminal using npx convex dev. This is crucial for your authentication configuration to be deployed and active Discord support thread: Convex Auth: Providers not configured (https://discord.com/channels/1019350475847499849/1273284005852090418).

  2. SITE_URL Configuration:
    Verify that you have correctly set up the SITE_URL environment variable. This should be set to your Convex deployment URL, not localhost Discord support thread: "Could not verify token claim" on React Native > Answers Part 1 (https://discord.com/channels/1019350475847499849/1277667704437735484).

  3. Resend Version:
    If you're using a recent version of the resend package, try downgrading it to version 3.2.0. There have been issues reported with newer versions Discord support thread: Next 14, Convex Auth Error (https://discord.com/channels/1019350475847499849/1263130273336262787).

#
  1. Error Logging:
    To get more detailed error information, modify your ResendOtp configuration to log the error before throwing:
if (error) {
  console.error(error);
  throw new Error(error.message);
}

This will help you identify if there are any issues with sending the email, such as using an unverified domain or sending to an email that's not associated with your Resend account during testing Discord support thread: Sign up user with custom fields > Answers Part 2 (https://discord.com/channels/1019350475847499849/1287623774249680967).

If after checking these points you're still encountering the error, it would be helpful to see the full error message from the console.error output. This could provide more specific information about why the auth provider is not being found.

Remember, when testing, you might only be able to send emails to the address you signed up with on Resend, or your emails might be marked as spam if you haven't verified your domain Auth > Config > Magic Links (https://labs.convex.dev/auth/config/email).

If the issue persists after verifying all these points, you may need to reach out to Convex support with more detailed error logs and your complete configuration for further assistance.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: