Hello everyone, I'm facing an issue in my project, called 401 Unauthorized AppwriteException: User (role: guests) missing scope (account, I'm appwite for backend as a servvice. when I'm creating an new account it will succussfully creates buut when I'm trying to LOGIN it dos'nt login . But if i try to go manually on Home page the i can go even i can create a post its working, and storage is also working but not with loggin
import { ID, Query } from "appwrite"; import { appwriteConfig, account, databases, storage, avatars } from "./config"; import { IUpdatePost, INewPost, INewUser, IUpdateUser } from "@/types"; export async function createUserAccount(user: INewUser) { try { const newAccount = await account.create( ID.unique(), user.email, user.password, user.name ); if (!newAccount) throw Error; const avatarUrl = avatars.getInitials(user.name); const newUser = await saveUserToDB({ accountId: newAccount.$id, name: newAccount.name, email: newAccount.email, username: user.username, imageUrl: avatarUrl, }); return newUser; } catch (error) { console.log(error); return error; } } export async function signInAccount(user: { email: string; password: string }) { try { const session = await account.createEmailSession(user.email, user.password); return session; } catch (error) { console.log(error); } } export async function saveUserToDB(user: { accountId: string; name: string; email: string; imageUrl: URL; username?: string; }) { try { const newUser = await databases.createDocument( appwriteConfig.databaseId, appwriteConfig.userCollectionId, ID.unique(), user ); return newUser; } catch (error) { log(error) } } export async function getAccount() { try { const currentAccount = await account.get(); return currentAccount; } catch (error) { console.log(error); } } export async function getCurrentUser() { try { const currentAccount = await getAccount(); if (!currentAccount) throw Error; const currentUser = await databases.listDocuments( appwriteConfig.databaseId, appwriteConfig.userCollectionId, [Query.equal("accountId", currentAccount.$id)] ); if (!currentUser) throw Error; return currentUser.documents[0]; } catch (error) { console.log(error); return null; } }
Recommended threads
- Error With iOS Apps
I keep getting the below errors for my flutter app. The clients are registered and have been. This wasn't an issue a few hours ago. AppwriteException: AppwriteE...
- Backup policies think im on free tier
Cant create more than one policy as im told to ugprade, when clicking upgrade im taken to the upgrade page which confirms im already on pro
- Cant get rid of "get started"
Not that important, but annoying. No matter what I do I cant get the "Get started" to go away, ive added a bunch of web platforms and its just stuck.