AppwriteException: user_unauthorized, The
current user is not authorized to perform
the requested action. (401) Getting this error continously```
<@&1201605261148815501> <@&634618551491100692>
I maybe could test it in an hour or so
<@999025209908666441> i have some questions regarding this:
- How are you calling it? Rest, CLI or SDK (and if yes which SDK)
- Did you verifify that you have an active session
- Are you using client SDK or server SDK or a mix of both both?
- Do you have guest access enabled in your project auth
- Do you have row (legacy document) level security turn on in that table (legacy collection)
Spot on. Didn't notice this reply earlier
^^
actually <@1073182954672627752> we are stupid with the first ig, it's tagged flutter
which answers the first question xD
I am using only client side, Flutter & using https://appwrite.io/docs/products/auth/presences & used this for documentation & its like chats App
Nice catch, nice catch๐
That narrows it down it down greatly to either RLS permission, or invalid session
could you run
try {
const user = await account.get({});
log(user.toString());
} catch (err) {
log(err);
}
before it to verify that you have a valid session
Error setting up presence: AppwriteException: user_unauthorized, The current user is not authorized to perform the requested action. (401)``` For the first time It is working but when I closes app & Started app then this error is showing up
do you have a valid session? what is the result of this snippet
I/flutter (27182): --- Account GET successful: {$id: 6a4b59ca430880c00c73, $createdAt: 2026-07-06T07:31:22.258+00:00, $updatedAt: 2026-07-07T12:52:48.191+00:00, name: arifqayoom39, password: null, hash: null, hashOptions: null, registration: 2026-07-06T07:31:22.257+00:00, status: true, labels: [], passwordUpdate: 2026-07-06T07:31:22.257+00:00, email: a*****39@gmail.com, phone: , emailVerification: false, emailCanonical: a*****39@gmail.com, emailIsFree: true, emailIsDisposable: false, emailIsCorporate: false, emailIsCanonical: true, phoneVerification: false, mfa: false, prefs: {data: {}}, targets: [{$id: 6a4b59ca4cad247aacea, $createdAt: 2026-07-06T07:31:22.314+00:00, $updatedAt: 2026-07-06T07:31:22.314+00:00, name: , userId: 6a4b59ca430880c00c73, providerId: null, providerType: email, identifier: a*****39@gmail.com, expired: false}], accessedAt: 2026-07-07T12:52:48.187+00:00, impersonator: false, impersonatorUserId: null} ---
This is the result I am getting
<@262572967358234634> For the first time it works well & show Online status to other user but when I closed this app & then restarted it shows I/flutter (27182): Error setting up presence: AppwriteException: user_unauthorized, The current user is not authorized to perform the requested action. (401)
<@999025209908666441> are you using the same ID for the upsert?
ID unique .. & Tried to use UserId alsso but nothing changed
how does your Presence call look like? <@999025209908666441>
final client = AppwriteConfig.client;
final presences = Presences(client);
try {
// 1. Mark self as online in this room
final p = await presences.upsert(
presenceId: ID.unique(),
status: 'online',
metadata: {'roomId': widget.room.id},
permissions: [
Permission.read(Role.users()), // Allow others to see our presence
],
);
_presenceId = p.$id;
// 2. Initial fetch to see if the other user is already online
final activeList = await presences.list(
queries: [Query.equal('userId', widget.user.id)],
);
bool found = false;
for (var presence in activeList.presences) {
if (presence.status == 'online' &&
presence.metadata?['roomId'] == widget.room.id) {
found = true;
break;
}
}
if (mounted) {
setState(() => _isOtherUserOnline = found);
}
// 3. Subscribe to presences
final realtime = AppwriteConfig.realtime;
_presenceSubscription = realtime.subscribe(['presences']);
_presenceSubscription.stream.listen((response) {
final payload = response.payload;
if (payload['userId'] == widget.user.id) {
final isDelete = response.events.any((e) => e.contains('.delete'));
final isOnline = payload['status'] == 'online';
final inRoom = payload['metadata']?['roomId'] == widget.room.id;
if (mounted) {
setState(() {
if (isDelete) {
_isOtherUserOnline = false;
} else {
_isOtherUserOnline = isOnline && inRoom;
}
});
}
}
});
} catch (e) {
print('Error setting up presence: $e');
}
}```
<@262572967358234634>
You are always creating a new id for the presence, i would recommend you to store presence id to make it persitent
Which is my last idea i have, if it still occurs then idk actually...
Recommended threads
- proccessing problems
A database schema operation is stuck in my Frankfurt project. In the matryq database, the workspaceId attribute of the coaching_activity_entries collection rema...
- User column is processing
I am still encountering the processing tag after creating a column in my database. and its not a network or refresh issue, i have refreshed over and over, shutd...
- Custom API domain is unreachable
Earlier my custom api domain was working fine. Now it seems to be offline without a trace a few hours later. I didn't change anything, all the relevant DNS reco...