ZachHandleyOriginal post
Moderator
So using the Server SDK and Astro, I have set the cookie session and I have this function that sets an API key or a session and returns a client, but for whatever reason I'm getting a general_unauthorized_scope for accounts.get() in the server SDK regardless of if I initiate it with a token or not
TypeScript
async getUser(): Promise<APIResponse<AuthUser>> { try { const user = await this.accounts.get(); console.log(user); return { status: 200, data: user, message: "User retrieved successfully", }; } catch (error) { // console.log("Error retrieving user:", error); return { status: 500, message: "Error retrieving user", }; } }TypeScript
export const getUserAppwriteClient = (request: AstroCookies): Client => { const sessionToken = request.has("session") ? request.get("session") : null; const client = new Client() .setEndpoint(import.meta.env.PUBLIC_APPWRITE_ENDPOINT) .setProject(import.meta.env.PUBLIC_APPWRITE_PROJECT_ID); if (sessionToken) { client.setSession(sessionToken.value); } else { client.setKey(import.meta.env.APPWRITE_SESSION_API_KEY); } return client;};but yeah I can't get it to work, just unauthorized over and over. Is this wrong for some reason?
Summary
Developers are encountering an `general_unauthorized_scope` error when trying to use `accounts.get()` with the Server SDK and Astro while using a session cookie. The provided code seems correct, but the issue persists.