Skip to content

Expose auth headers, cookies, and OkHttpClient for external networking clients#117

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/expose-auth-cookies-headers
Closed

Expose auth headers, cookies, and OkHttpClient for external networking clients#117
Copilot wants to merge 2 commits intomainfrom
copilot/expose-auth-cookies-headers

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 29, 2026

No clean public API existed to reuse the SDK-managed session with external libraries (Coil, Glide, custom OkHttp clients). Apps were forced to read internal SharedPreferences keys directly (e.g. "myCookie"), coupling them to undocumented SDK internals.

New public methods on Client

  • getHeaders(): Map<String, String> — immutable copy of current request headers (x-appwrite-project, x-appwrite-session, x-appwrite-jwt, etc.)
  • getCookies(url: String): List<Cookie> — session cookies from the SDK's cookie jar for a given URL, without touching SharedPreferences directly
  • getHttpClient(): OkHttpClient — a new OkHttpClient built from the SDK's configuration that shares the cookie jar, so session cookies are sent automatically on every request

Usage example

// Coil: authenticated image loading from Appwrite Storage
val imageLoader = ImageLoader.Builder(context)
    .okHttpClient(client.getHttpClient())
    .build()

// Manual: attach headers to a third-party request
val headers = client.getHeaders()
val cookies = client.getCookies("https://cloud.appwrite.io")

getHttpClient() returns http.newBuilder().build() — a defensive copy that shares the cookie jar but is isolated from the SDK's internal OkHttpClient instance.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.5-bin/5t9huq95ubn472n8rpzujfbqh/gradle-8.5/lib/gradle-launcher-8.5.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.5-bin/5t9huq95ubn472n8rpzujfbqh/gradle-8.5/lib/agents/gradle-instrumentation-agent-8.5.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.5 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI changed the title [WIP] Expose auth cookies or request headers for external clients Expose auth headers, cookies, and OkHttpClient for external networking clients Mar 29, 2026
Copilot AI requested a review from ChiragAgg5k March 29, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose auth cookies or request headers for external clients

2 participants