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
- Functions not executing after usage rese...
Hi team, Last month my project hit 100% usage and functions stopped working (expected). Now the new month has started and usage has reset, requests are going ...
- Functions never end and always fail (sta...
Hi ! I'm using Appwrite Cloud Pro and function execution from appwrite website is KO. Deploying starter function template, execution is always Failed and the ...
- My function executions console if overwh...
It seems the requests are getting processed correctly but it is using a older version of the backend. And it seems the cron requests done an hour ago are shown ...