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
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...
- Deep Linking & Password reset
I am using react native with expo. I want to implement deep link with the url recived via email. So when clicked the link it opens my app. I havent ever used de...