mirror of
https://github.com/appwrite/sdk-for-android.git
synced 2026-04-07 19:17:49 +00:00
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:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user