#[SOLVED] (role: applications) missing scope (account)

3 messages · Page 1 of 1 (latest)

atomic solstice
#

i'm refactoring my code, but I'm getting this issue when trying to get the current user logged in. My api key is correct with all auth/database scopes. Here are my codes:

Appwrite service

class AppwriteService {
    private static adminClient: Client;
    private static getAdminClient(): Client {
        if (!this.adminClient) {
            this.adminClient = new Client()
                .setEndpoint(APPWRITE_ENDPOINT)
                .setProject(APPWRITE_PROJECT)
                .setKey(APPWRITE_API_KEY);
        }
        return this.adminClient;
    }
    public static getAppwriteAdminClient() {
        const client = this.getAdminClient();
        return {
            get account() {
                return new Account(client);
            },
            get users() {
                return new Users(client);
            },
            get databases() {
                return new Databases(client);
            },
        };
    }
}

export default AppwriteService;

Auth service

class AuthService {
    private static readonly account: Account = AppwriteService.getAppwriteAdminClient().account;

    public static async getLoggedInUser(): Promise<Models.User<Models.Preferences>> {
        return await this.account.get();
    }
}
export default AuthService;

usage in page.tsx

  const isLoggedIn = await AuthService.getLoggedInUser()
fervent nexus
atomic solstice