Skip to content

🐛 Bug Report: ApiClient.account.get(); throw an error #62

@Tananga

Description

@Tananga

👟 Reproduction steps

Just call ApiClient.account.get() when you are not loged in. I expected to get a null but this is not nullable value. Im getting something like this

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: AppwriteException: general_unauthorized_scope, User (role: guest) missing scope (account) (401)
E/flutter (18416): #0 ClientMixin.prepareResponse (package:appwrite/src/client_mixin.dart:73:9)
E/flutter (18416): #1 ClientIO.call (package:appwrite/src/client_io.dart:256:14)
E/flutter (18416):
E/flutter (18416): #2 Account.get (package:appwrite/services/account.dart:20:17)
E/flutter (18416):
E/flutter (18416): #3 MyHomePage.getAccount (package:tanangaapps/main.dart:66:23)
E/flutter (18416):

And this is how it looks in account.dart appwrite file:

/// Get Account
///
/// Get currently logged in user data as JSON object.
///
Future<models.User> get() async {
const String path = '/account';

final Map<String, dynamic> params = {};

final Map<String, String> headers = {
  'content-type': 'application/json',
};

final res = await client.call(HttpMethod.get,
    path: path, params: params, headers: headers);
return models.User.fromMap(res.data);

}

👍 Expected behavior

It should return null or empty user

👎 Actual Behavior

ERROR. Is it ok? It looks wierd

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

MacOS

🧱 Your Environment

I use digitalOcean Appwrite 0.13.4 and my apprwite version in pubspec.yaml : appwrite: ^4.0.2

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions