Robert RamirezOriginal post
Rank 1: Thread
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
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
}
func logout() async throws {
do {
let response = try await account.deleteSession(sessionId: "current")
print("logout \(response)")
} catch {
print("Error logging out: \(error)")
}
}
func getLoggedInUser() async throws -> User<[String: AnyCodable]> {
let user = try await account.get()
return user
}
Summary
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.