Hi, i am currently creating an app with appwrite but I have an issue. I added verification via email and password to it, which works just fine. But now I want to add Email verification to it, but as soon as i call account.createVerification(<MyURL>) it gives an error:
AppwriteException: ...@service.cloud.appwrite.io (role: applications) missing scope (account)
export const createAccount = async ({
fullName,
email,
password,
}: {
fullName: string;
email: string;
password: string;
}) => {
const existingUser = await getUserByEmail(email);
if (!existingUser) {
const { databases, account } = await createAdminClient();
try {
const user = await account.create(ID.unique(), email, password, fullName);
const accountId = user.$id;
await databases.createDocument(
appwriteConfig.databaseId,
appwriteConfig.usersCollectionId,
ID.unique(),
{
fullName,
email,
avatar: avatarPlaceholderUrl,
accountId,
}
);
const session = await account.createEmailPasswordSession(email, password);
(await cookies()).set("APPWRITE_SESSION", session.secret, {
path: "/",
httpOnly: true,
sameSite: "strict",
secure: true,
});
await account.createVerification("http://localhost:3000/verify");
return parseStringify({ accountId });
} catch (error) {
handleError(error, "Failed to create account");
}
}
return parseStringify({ message: "User already exists" });
};
Role: applications means you're using an API key. But you're trying to make a request that needs to be done as a user (scope account)
Okay, but how can I do it as a user then? That is what I don't find
Maybe you can try creating the session client and using that
Recommended threads
- Sydney Cloud Sites: App Git deployment a...
Project ID: rentwize-db The app Site fails after the build completes with a missing build archive error. Site id: app Framework: TanStack Start SSR Output dir...
- Active Running Project Deletion Alert Em...
Hi , I received an email alert from Appwrite today stating “your project will be deleted within 14 days if no action is taken,” though I have been actively usin...
- Project restoration button in console
The project restore button in console is taking no effect, i have tried several times and still nothing, it gives same popup if i reload