
AppwriteException: User (role: guests) missing scope (account) at Client.<anonymous> (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=5dc19954:850:17) at Generator.next (<anonymous>) at fulfilled (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=5dc19954:488:24)

Can you share the code?

yaa sure is there anu commnd to store in thread or directly i will send here

import authservice from './Services/Auth';
import './index.css' /* eslint-disable no-undef */ import React, { useEffect, useState } from 'react'; import './App.css'; import { useDispatch } from 'react-redux'; import { Header, Footer } from './components'; import { login, logout } from './store/authslice';
function App() { const [isLoading, setIsLoading] = useState(true); const dispatch = useDispatch();
useEffect(()=>{
authservice.getcurrentuser()
.then((userData)=>{
if (userData){
dispatch(login({userData}))
}
else{
dispatch(logout())
}
})
.finally(()=>setIsLoading(false))
},[])
return !isLoading ?( <div className='min-h-screen flex flex-wrap content-between bg-gray-400'>
<div className='w-full block'>
<Header/>
<Footer />
</div>
</div>
):null
}
export default App;

So the error is from
authservice.getcurrentuser()
This is normal as the user is not logged in

You should catch it

can i sahre the auth service code

Sure

import { Client, Account,ID } from "appwrite";
import conf from "../conf/conf";
// Create a class for Appwrite client export class Authservice { client = new Client(); account; constructor() {
this.client.setEndpoint(conf.appwriteurl)
.setProject(conf.appwriteProjectid);
this.account=new Account(this.client)
}
async signup({email, password,name}) {
try {
// Use the Appwrite Account API to create a new user
const useraccount=await this.account.create(ID.unique(),email, password,name);
if (useraccount) {
return this.login({email,password})
}
else {
return useraccount
}
} catch (error) {
console.error('Error during signup:', error);
}
}
async login({email, password}) {
try {
return await this.account.createEmailSession(email, password);
} catch (error) {
console.error('Error during login:', error);
}
}
async is_loggedin(){
try {
return await this.account.get();
} catch (error) {
console.log('you corresponding appwrite error is:',error)
}
return null;
}
async logout(){
try {
this.account.deleteSessions();
} catch (error) {
console.log('you corresponding appwrite error is:',error)
}
}
async getcurrentuser(){
try {
const loggeddin=await this.account.get()
return loggeddin
} catch (error) {
console.log(error)
return null
}
}

}
// Create an instance of AppwriteClient const authservice = new Authservice();
export default authservice;

This is good

Which console.log
is the error you're getting?

AppwriteException: User (role: guests) missing scope (account) at Client.<anonymous> (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=5dc19954:850:17) at Generator.next (<anonymous>) at fulfilled (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=5dc19954:488:24)

here this one

But from which one
async getcurrentuser(){
try {
const loggeddin=await this.account.get()
return loggeddin
} catch (error) {
console.log(error)
return null
}
}

Like here for example The error is normal

which one

The error you're getting means that the user is not logged in when you're trying to get the user
Recommended threads
- Stuck in "deleting"
my parent element have relationship that doesnt exist and its stuck in "deleting", i cant delete it gives me error: Collection with the requested ID could not b...
- Help with 409 Error on Relationship Setu...
I ran into a 409 document_already_exists issue. with AppWrite so I tried to debug. Here's what I've set up: Collection A has 3 attributes and a two-way 1-to-m...
- Database Double Requesting Error.
I am getting error for creating new document in an collection with new ID.unique() then too getting error of existing document. When button is pressed one docum...
