appwrite / sdk-generator

Generating SDKs for multiple programming languages and platforms ⚙️
https://appwrite.io
MIT License
272 stars 168 forks source link

🐛 Bug Report: Login with Windows does not work #880

Closed Kuromory closed 3 months ago

Kuromory commented 3 months ago

👟 Reproduction steps

I use the selfhosted version of appwrite (1.5.7) and want to login with email/password. here is the code

 var session = await _account.createEmailPasswordSession( // here I get the userId/email etc. from the session variable (session.toMap())
        email: event.email,
        password: event.password,
      );
      final user = await _account.get(); // here I get the error
      final teams = await _teams.list();

👍 Expected behavior

I get the account values like name/team memberships etc.

👎 Actual Behavior

I get this error: flutter: AppwriteException: general_unauthorized_scope, User (role: guests) missing scope (account) (401) flutter: #0 ClientMixin.prepareResponse (package:appwrite/src/client_mixin.dart:73:9)

1 ClientIO.call (package:appwrite/src/client_io.dart:383:14)

#2 Account.get (package:appwrite/services/account.dart:20:17) here is what docker tells me: 2024-06-17 09:42:08 appwrite | [Error] Timestamp: 2024-06-17T07:42:08+00:00 2024-06-17 09:42:08 appwrite | [Error] Method: GET 2024-06-17 09:42:08 appwrite | [Error] URL: /v1/account 2024-06-17 09:42:08 appwrite | [Error] Type: Appwrite\Extend\Exception 2024-06-17 09:42:08 appwrite | [Error] Message: User (role: guests) missing scope (account) 2024-06-17 09:42:08 appwrite | [Error] File: /usr/src/code/app/controllers/shared/api.php 2024-06-17 09:42:08 appwrite | [Error] Line: 273 ### 🎲 Appwrite version Different version (specify in environment) ### 💻 Operating system Windows ### 🧱 Your Environment like I said I use the docker compose selfhosted file provided from the website on my windows machine with WSL2 version 1.5.7 ### 👀 Have you spent some time to check if this issue has been raised before? - [X] I checked and didn't find similar issue ### 🏢 Have you read the Code of Conduct? - [X] I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)
byawitz commented 3 months ago

Hi @Kuromory Thanks for opening the issue. Appwrite's get function would throw an error when the user is not logged in, this is the expected behavior. Though, the createEmailPasswordSession should initiate the session, to further debug it you can wrap both functions in try/catch blocks to see why the session creation didn't went through.

try {
  var session = await _account.createEmailPasswordSession( 
          email: event.email,
          password: event.password,
  );
} catch (e) {
  // ...
}

try {
  final user = await _account.get();
} catch (e) {
  // ...
}

final teams = await _teams.list();

Or create a support ticket in our Discord

Kuromory commented 3 months ago

Hey @byawitz I have all in a try/catch block but for testing I did it like you told me so and it still does NOT work... Just that you know, when I use web (Chrome) it does work without a problem... it only does not work on windows... It also worked around 2 weeks ago... but since then I updated appwrite and flutter to the newest version, maybe this was the cause it wont work anymore?

byawitz commented 3 months ago

What's the error in Windows? for the first try/catch block?

Kuromory commented 3 months ago

If you mean in the method createEmailPasswordSession then there is no error... I just get the error after "sucessful" Login... I also have the session in my appwrite dashboard visible...

Kuromory commented 3 months ago

Do you guys create some kind of file/cache or something that might needed to be deleted? I added OAuth2 support to my app and it might got some things mixed up where it can't detect I am already logged in?

Kuromory commented 3 months ago

I got it working! I had to delete your guys %USERNAME%\Documents\cookies\ folder... you might wanna tell people in your docs where you save your stuff... took me now over a week to find it...