Ideally I would like to be able to sign in anonymously and persist this user even if they close and reopen the app. Is this possible? Here is what I currently have:
TypeScript
static func ensureUserSession() async -> Result<User, Error> {
let account = Account(client)
do {
let user = try await account.get()
return .success(User(id: user.id))
} catch {
do {
let session = try await account.createAnonymousSession()
print(session.userId)
return .success(User(id: session.userId))
} catch {
return .failure(error)
}
}
}
My issue is twofold:
- Every time I run the app the account.get() fails with the error
User (role: guests) missing scope (account) - When it goes to my catch and calls createAnonymousSession() it succeeds, but creates a new user everytime as I can see in my dashboard.
I do have anonymous login enabled in my dashboard. Am I missing something else?
TL;DR
1. User session creation on app launch is failing due to missing scope error.
2. Anonymous session creation successful but results in new user creation each time.
Solution: Check if the account has necessary scope for the user role. Make sure anonymous login configuration is correctly set up in the dashboard.Recommended threads
- TSL Certificate Issues
Hi Appwrite Discord Community, I got a problem with my Self-Hosted instance. I only want, that I can use my programm with the Appwrite Backend without .selfSig...
- React Native/iOS platform integrations h...
Anyone else have this issue where platform identifiers have been lost/wiped and no option/field available to update them in the console?
- macOS app: OAuth flow doesn’t start
Hi Appwrite team, I’m integrating the Appwrite Swift SDK into a macOS app and am hitting an environment/runtime issue when starting OAuth. App architecture • ...