I looked back at Appwrite 0.12 and I didn't find anything in the API about creating an account converting an anonymous user 🧐
👀 It is supposed to be automatic.... maybe that was the plan but we never implemented it...
@Steven Did something change in the last few days? The updateEmail is not working anymore on an anonymous session. Get this error: AppwriteException: general_unauthorized_scope, User (role: guests) missing scope (account) (401)
You're seeing this error because you don't have a valid (anonymous) session.
But the dashboard shows a valid session. I created an anon session, and then immediately after tried to update the email. (By this time, dashboard has been updated with the new anon entry)
You may not be using the session in the update email API call. Or maybe not waiting until the session is created before executing the update email API call.
What's your code?
To make sure that you're attaching an email/passsword to an anonymouse session, you need to make sure that the user is IN the anonymous session.
If you could show some code, we'd have much more clarity on what could be the issue.
This is the session object I got after I created the anonymous session. (attachment below)
Future<void> createAnonSession() async {
try {
models.Session user = await account.createAnonymousSession();
print(user.userId);
} catch (e) {
throw Exception('Failed to create anon session $e');
}
}```
And to update user details:
models.Account accountData = await account.updateEmail( email: email, password: password, );
These are separate callback calls from different buttons, which i'm triggering separately, so its not async sync issue for sure.
Similar issue with phone auth. Logged in with phone number and OTP, all successful, got the session object as a result. In the dashboard, you see the session is created too, but getting the error general_unauthorized_scope, User (role: guests) missing scope (account) (401)
How are account and Client instantiated and used?
Same problem. role: guests
indicates you don't have a session
It's a simple object creation:
authRepo = AppwriteAuthRepo(Account(client));
and repo class:
class AppwriteAuthRepo implements AuthRepo {
final Account account;
AppwriteAuthRepo(this.account); }```
client object creation is exactly like the demos/docs.
The same account object is used in the OAuth or email-password methods and session is created then, but not working in phone now, and updating Anon details. This was working before I'm guessing.
same Client and Account instance used between the session creation and updating email?
So I created this minimum reproducible code for you to try it at your end, I was able to get the same error in this code as well. Please check the code and possibly also run it and you should get an error when you tap the update button. And if there is something wrong in my code, let me know, thanks!
https://gist.github.com/PoojaB26/8b0221e823e3749c86e4afdeecb149fc
Thanks! I'll try to find some time today to test this
are you using HTTPS for your endpoint?
and i have appwrite: ^8.3.0
btw
Sorry, I was away for sometime.
Anyway, I'm running on my localhost, is that the issue? The API endpoint given in the dashboard is this, I dont see anyway to change it. Are you running on a custom domain? But anyway it should still work on localhost as well, right?
Hi @PoojaBhaumik Can you show the client init in your code?
the complete code is here : https://gist.github.com/PoojaB26/8b0221e823e3749c86e4afdeecb149fc
Shouldn't be...I also tested again with http://10.0.2.2/v1
and https://10.0.2.2/v1
as my endpoints and they both worked.
What version of Appwrite do you have?
Also, the endpoint you see is always the URL you accessed Appwrite at. So if you browse to https://localhost/
(and accept the self signed warning) the endpoint will show https://localhost/v1
+1 I’m making a new flutter app where users need a session to earn and buy tokens. So they need a session, mostly they first try the app without sign up (anon session) my surprise is when users sign up enter their email/password, another user is created and lost their “anonymous” tokens (because their have a new userId)
My b, updatePassword and updateEmail should be works, I’ll try tomorrow 🐥
Recommended threads
- Current User is Not authorized
recreating same Thread
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...