Skip to content
Back

Unable to get account or logout after a successful login in ios

  • 0
  • Auth
  • Apple
  • Cloud
Robert Ramirez
20 May, 2025, 19:57

I get the following error after a successful login when ever I call account.get() or account.deleteSession(sessionId: "current"). User (role: guests) missing scope (account)

I am able to print the session and user id after login

TypeScript
func login(_ email: String, _ password: String) async throws -> Session {
  let session = try await account.createEmailPasswordSession(email: email, password: password)
  self.isLoggedIn = true
  print("Session \(session.current)")
  return session
}
TypeScript
func logout() async throws {
  do {
    let response = try await account.deleteSession(sessionId: "current")
    print("logout \(response)")
  } catch {
    print("Error logging out: \(error)")
  }

}
TypeScript
func getLoggedInUser() async throws -> User<[String: AnyCodable]> {
  let user = try await account.get()
  return user
}
TL;DR
Issue: After successful login, developers are encountering an error "User (role: guests) missing scope (account)" when trying to use `account.get()` or `account.deleteSession(sessionId: "current")`. Solution: Ensure that the user has the necessary scope permissions for the account actions. Double-check the role settings and adjust as needed.
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