Skip to content
Back

Error: User (role: guests) missing scope (account)

  • 0
  • Auth
  • Apple
oke
11 Dec, 2024, 18:21

I want to send a verification code to the user and the given phone number and check it and create a session right after the user entered the secret. For me that worked out perfect but after that I want to change the users name but everytime I want to run this it gives me the following error: Error: User (role: guests) missing scope (account). Even if the session is created and is listed on the console of Appwrite. Also happens when running account.get() class Cloud { var client: Client var account: Account var userid = "" var sessionId: String? public init() { self.client = Client() .setEndpoint("https://cloud.appwrite.io/v1") .setProject("MY_PROJECT_ID") self.account = Account(client) } func sendCode(number: String) { Task { do { let token = try await account.createPhoneToken( userId: ID.unique(), // User-ID wird automatisch generiert phone: number ) self.userid = token.userId print("Code wurde gesendet. User-ID: token.userId)") } catch { print("Error1: Failed to send phone token. Error: error.localizedDescription)") } } } func verifyAccount(code: String) { Task { do { var session = try await account.createSession( userId: self.userid, secret: code ) _ = client.setSession(session.id) _ = try await account.updateName(name: "Peter") self.sessionId = session.id print("session created successfully: session.id)") // Ändere $id zu id } catch { print("Error2: Failed to verify account. Error: error.localizedDescription)") } } } }

TL;DR
Error message occurs when attempting to change user's name after creating session. Error: User (role: guests) missing scope (account). Solution: Ensure user has appropriate permissions or roles granted for account management.
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