Skip to content
Back

Email Verification Error

  • 1
  • Auth
  • Web
  • Cloud
Jenil Desai
24 Jun, 2025, 05:35

I am trying to make a registration flow for the next.js using node-appwriter sdk as SSR. I am trying to add email verification but isn't working giving some errors:

TypeScript
(role: application) missing scope account

I have gave all the scope permissions in the API. Then too getting this error. Anyone know then it will be great full.

My current register user code looks like:

TypeScript
"use server";
import { createAdminClient } from "@/lib/appwrite";
import { RegisterFormData, registerSchema } from "@/schemas/register";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import { AppwriteException, ID } from "node-appwrite";

export async function registerUser(data: RegisterFormData) {
  const validatedData = registerSchema.safeParse(data);
  if (!validatedData.success) {
    return {
      success: false,
      errors: validatedData.error.errors.map((error) => ({
        field: error.path.join("."),
        message: error.message,
      })),
    }
  }

  const { fullName, email, password } = validatedData.data;
  const { account } = await createAdminClient();

  try {
    await account.create(ID.unique(), email, password, fullName);
    const session = await account.createEmailPasswordSession(email, password);
    const cookieStore = await cookies();
    cookieStore.set("custom-auth-session", session.secret, {
      path: "/",
      httpOnly: true,
      sameSite: "strict",
      secure: true,
    });
    await account.createVerification("http://rnhyg-2409-40c1-3085-5d34-d518-3aa8-c6ca-460d.a.free.pinggy.link/auth/verify-email");
    redirect("/verify-email");
  } catch (error) {
    if (error instanceof AppwriteException) {
      const response = JSON.parse(error.response ?? '{}') ?? {};
      return {
        success: false,
        errors: [{ field: "general", message: response.message }],
      };
    } else {
      return {
        success: false,
        errors: [{ field: "general", message: "An unexpected error occurred" }],
      };
    }
  }
}
TL;DR
Developers are facing an email verification error while implementing registration flow in Next.js using node-appwrite SDK. The specific error is "role: application missing scope account". This issue could be due to missing scope permissions in the API configuration. To resolve this error, double-check the scope permissions in the API configuration to ensure the required permissions are granted for the account.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more