feat: expose auth headers, cookies and OkHttpClient for external clients

Agent-Logs-Url: https://github.com/appwrite/sdk-for-android/sessions/9569030c-c1fe-42d1-b402-75466e5875d5

Co-authored-by: ChiragAgg5k <110609663+ChiragAgg5k@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-29 18:01:43 +00:00
parent 0fa587570f
commit cf218008d9
2 changed files with 33 additions and 0 deletions
Vendored Regular → Executable
View File
@@ -314,6 +314,39 @@ class Client @JvmOverloads constructor(
return this
}
/**
* Get the current request headers used for Appwrite API calls.
*
* This can be used to authenticate requests with external networking
* libraries such as Coil or Glide when loading protected Appwrite Storage files.
*
* @return an unmodifiable map of the current request headers
*/
fun getHeaders(): Map<String, String> = headers.toMap()
/**
* Get the cookies for a given URL from the SDK's cookie store.
*
* This can be used to authenticate requests with external networking
* libraries such as Coil or Glide when loading protected Appwrite Storage files.
*
* @param url the URL to retrieve cookies for
* @return a list of cookies for the given URL
*/
fun getCookies(url: String): List<Cookie> = cookieJar.loadForRequest(url.toHttpUrl())
/**
* Get the OkHttpClient instance used by this SDK.
*
* The returned client is pre-configured with the SDK's cookie jar so it
* automatically includes session cookies on every request. Pass it directly
* to external networking libraries (e.g. Coil, Glide, or a custom OkHttp
* client) to reuse the current authenticated session.
*
* @return the OkHttpClient instance used by this client
*/
fun getHttpClient(): OkHttpClient = http.newBuilder().build()
/**
* Sends a "ping" request to Appwrite to verify connectivity.
*