Skip to content
Back

400, Message: {path: /logout, error: AppwriteException: user_key_and_session_set}

  • 0
  • Functions
  • Cloud
Ankit Maniya
14 Apr, 2025, 22:50

Error: 400, Message: {path: /logout, error: AppwriteException: user_key_and_session_set, API key and session used in the same request. Use either setSession or setKey. Learn about which authentication method to use in the SSR docs: https://appwrite.io/docs/products/auth/server-side-rendering (403)}

Header From My Cloud function

TypeScript
{cf-connecting-ip: 205.206.125.158, x-real-ip: 172.69.156.149, 
    accept-encoding: gzip, br, cf-ipcountry: CA, 
    authorization: Basic XXXXXXXk0YWI3XXXXXXX, 
    x-appwrite-key: XXXXXXXX, 
    x-forwarded-proto: https, content-length: 68, cf-ray: 9306b8aeXXXXXXX-YYC, user-agent: Dart/3.4 (dart:io), cdn-loop: cloudflare; loops=1, x-appwrite-country-code: CA, 
    content-type: application/json, x-appwrite-continent-code: NA, cf-visitor: {"scheme":"https"}, 
    accept: */*, x-forwarded-port: 443, x-forwarded-server: traefik-XXXXXXX-8qp8x, x-forwarded-host: 67f6b8f47479XXXXXXX.appwrite.global, 
    host: 67f6b8f47479c8113546.appwrite.global, x-appwrite-continent-eu: false, x-appwrite-trigger: http, x-forwarded-for: XXX.XXX.XXX.XXX, XXX.XXX.XXX.XXX}

TL;DR
Developers are encountering a 400 error related to using both **setKey** and **setSession** in the same request. The issue is caused by passing both x-appwrite-key and x-appwrite-user-session-secret headers. To resolve this, choose either **setKey** or **setSession** for authentication, not both. The error message provides a link to the correct authentication method.
Ankit Maniya
14 Apr, 2025, 22:52

I am passing x-appwrite-key to setKey then I'm passing x-appwrite-user-session-secret to setSession

How to perform clean for each in Cloud Function

Ankit Maniya
14 Apr, 2025, 22:54

In cloud function init the client so when I req second time does it clean up older client setKey or setSession and init with newer everytime??

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more