Always use the authentication method appropriate for your API client's execution context. Server-side SDKs should use API key authentication (with `setKey()`) rather than session-based authentication, which is meant for client-side applications.
Always use the authentication method appropriate for your API client’s execution context. Server-side SDKs should use API key authentication (with setKey()
) rather than session-based authentication, which is meant for client-side applications.
Why it matters:
setSession()
) won’t function properly in server contextsExample - PHP Server SDK:
$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
->setProject('<YOUR_PROJECT_ID>')
->setKey('<YOUR_API_KEY>'); // Correct: Using API key for server authentication
// ->setSession(''); // Incorrect: Session auth doesn't work server-side
Example - Kotlin Server SDK:
val client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1")
.setProject("<YOUR_PROJECT_ID>")
.setKey("<YOUR_API_KEY>") // Correct: Using API key for server authentication
// .setSession("") // Incorrect: Session auth doesn't work server-side
Enter the URL of a public GitHub repository