Back

PHP (Laravel) deleteSession('current') got error missing scope (account)

  • 0
  • Auth
  • Web
Gifanda Delasty
1 Jan, 2025, 03:21

Hi, nice to meet you! Apologies in advance, as I’m new to Appwrite and currently migrating from Firebase.

In my current project, I’m using PHP with Laravel, and I’m implementing user authentication system (Login and Logout). However, I seem to have missed something, as I encountered an error during the logout process: (role: applications) missing scope (account).

I’d greatly appreciate your help in identifying where I might have gone wrong. Here, I’ve included the code for both Login and Logout.

Thank you so much in advance for your support, and I'm sorry for taking up your time.

TL;DR
Developer encountered an error `(role: applications) missing scope (account)` during logout using Laravel in PHP. Possible issues with session management and authentication process. Suggestions were made to check if user has an active session before deleting, confirm proper authentication, and review code for `$client` in Laravel's AppServiceProvider. Ensure consistent `Client` instance usage.
Darshan Pandya
1 Jan, 2025, 03:25

are you using the same Client instance in the method params or creating a new one?

Gifanda Delasty
1 Jan, 2025, 03:28

Oh, I forgot to include the code for $client in Laravel's AppServiceProvider. Here's the code attached.

Darshan Pandya
1 Jan, 2025, 03:35

Assuming this is a singleton that is consistent across the entire session, it seems okay. I am also assuming the setSession('user') is either a placeholder or do you do some data injection there? As it needs to be the user session and not just user. I am not entirely sure but (role: applications) missing scope (account) already means that the user is not signed in. Does this happen only on logout?

Gifanda Delasty
1 Jan, 2025, 03:41

I’ve updated the code and removed the setSession('user') part, as it was just something I tried while troubleshooting the error.

This issue happens when I click Logout, and it seems like the session isn’t actually deleted. There was a point during my code adjustments where it redirected to the login page (as if it worked), but when I manually accessed the dashboard page, it allowed access (as if the session was still active).

Finally, when I rewrote the code from scratch, it didn’t work and resulted in the missing scope error that we’re currently discussing.

Darshan Pandya
1 Jan, 2025, 03:44

can you confirm if the user has session before deleting? maybe try account->get() and print it? does it print the user info?

Gifanda Delasty
1 Jan, 2025, 03:46

Ahh, I see. Let me try implementing it first and I’ll update the results here.

Gifanda Delasty
1 Jan, 2025, 03:56

Hi, here are the results I got. It seems like the account isn’t actually logged in, right? I think I don’t fully understand how to authenticate users. Could the issue be with the login process? 😟

Darshan Pandya
1 Jan, 2025, 03:59

I think the issue might be the fact that you might are not using the session on the client after login [setSession]. You are using setKey as well, not sure if its required. Refer - https://appwrite.io/blog/post/introducing-support-for-server-side-rendering, the example uses js/react but should give you an idea.

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