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
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",
};
}
}
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?
Recommended threads
- All projects deleted
Hello, from the appwrite console last week I re-activated some of my old project and published them, yesterday I checked and none of the apps were working, now ...
- My account got banned without obvious re...
Hello, I’m a normal user of Appwrite. Today I found my account was banned suddenly, and I can’t log in normally. I have only been doing normal development and...
- cant resume project
Invalid console fingerprint event i try man time