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)") } } } }
Recommended threads
- Flutter OAuth2 does not attach Google se...
Hi Appwrite team, I’m using Appwrite Auth in a Flutter mobile app and trying to upgrade an anonymous user to Google OAuth. Docs say that if there is already a...
- Bug report: Race condition in Flutter SD...
Hi team, I've found an intermittent bug in the Flutter SDK (v20.3.0) when using `createOAuth2Session` on Android. **Symptoms** After `createOAuth2Session` re...
- Register Disable
this is possible disable register but keep oauth login?