> ## Documentation Index
> Fetch the complete documentation index at: https://docs-staging.auth0-mintlify.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Auth0.Android Custom Networking Client

> Learn how to provide a custom networking client to customize requests made by the Auth0 Android SDK.

export const AuthCodeBlock = ({filename, icon, language, highlight, children}) => {
  const [displayText, setDisplayText] = useState(children);
  const [copyText, setCopyText] = useState(children);
  const wrapperRef = React.useRef(null);
  useEffect(() => {
    let unsubscribe = null;
    function init() {
      if (!window.autorun || !window.rootStore) {
        return;
      }
      unsubscribe = window.autorun(() => {
        let processedChildrenForDisplay = children;
        let processedChildrenForCopy = children;
        for (const [key, value] of window.rootStore.variableStore.values.entries()) {
          const escapedKey = key.replaceAll(/[.*+?^${}()|[\]\\]/g, (String.raw)`\$&`);
          let displayValue = value;
          if (key === "{yourClientSecret}" && value !== "{yourClientSecret}") {
            displayValue = value.substring(0, 3) + "*****MASKED*****";
          }
          processedChildrenForDisplay = processedChildrenForDisplay.replaceAll(new RegExp(escapedKey, "g"), displayValue);
          processedChildrenForCopy = processedChildrenForCopy.replaceAll(new RegExp(escapedKey, "g"), value);
        }
        setDisplayText(processedChildrenForDisplay);
        setCopyText(processedChildrenForCopy);
      });
    }
    if (window.rootStore) {
      init();
    } else {
      window.addEventListener("adu:storeReady", init);
    }
    return () => {
      window.removeEventListener("adu:storeReady", init);
      unsubscribe?.();
    };
  }, [children]);
  useEffect(() => {
    if (!wrapperRef.current) return;
    const originalWriteText = navigator.clipboard.writeText.bind(navigator.clipboard);
    let isOverriding = false;
    const handleClick = e => {
      const button = e.target.closest('[data-testid="copy-code-button"]');
      if (!button || !wrapperRef.current.contains(button)) return;
      isOverriding = true;
      navigator.clipboard.writeText = text => {
        if (isOverriding) {
          isOverriding = false;
          navigator.clipboard.writeText = originalWriteText;
          return originalWriteText(copyText);
        }
        return originalWriteText(text);
      };
      setTimeout(() => {
        if (isOverriding) {
          isOverriding = false;
          navigator.clipboard.writeText = originalWriteText;
        }
      }, 100);
    };
    const wrapper = wrapperRef.current;
    wrapper.addEventListener('click', handleClick, true);
    return () => {
      wrapper.removeEventListener('click', handleClick, true);
      if (navigator.clipboard.writeText !== originalWriteText) {
        navigator.clipboard.writeText = originalWriteText;
      }
    };
  }, [copyText]);
  return <div ref={wrapperRef}>
      <CodeBlock filename={filename} icon={icon} language={language} lines highlight={highlight}>
        {displayText}
      </CodeBlock>
    </div>;
};

export const codeExample1 = `val netClient = DefaultClient.Builder()
    .connectTimeout(30)
    .readTimeout(30)
    .writeTimeout(30)
    .callTimeout(120)
    .build()

val account = Auth0.getInstance("{yourClientId}", "{yourDomain}")
account.networkingClient = netClient`;

export const codeExample2 = `val netClient = DefaultClient.Builder()
    .enableLogging(true)
    .build()

val account = Auth0.getInstance("{yourClientId}", "{yourDomain}")
account.networkingClient = netClient`;

export const codeExample3 = `val netClient = DefaultClient.Builder()
    .defaultHeaders(mapOf("YOUR_HEADER_NAME" to "YOUR_HEADER_VALUE"))
    .build()

val account = Auth0.getInstance("{yourClientId}", "{yourDomain}")
account.networkingClient = netClient`;

export const codeExample5 = `val netClient = DefaultClient.Builder()
    .enableLogging(true)
    .logger(HttpLoggingInterceptor.Logger { message -> Log.d("Auth0Http", message) })
    .build()`;

export const codeExample4 = `class CustomNetClient : NetworkingClient {
    override fun load(url: String, options: RequestOptions): ServerResponse {
        // Create and execute the request to the specified URL with the given options
        val response = // ...

        // Return a ServerResponse from the received response data
        return ServerResponse(responseCode, responseBody, responseHeaders)
    }
}

val account = Auth0.getInstance("{yourClientId}", "{yourDomain}")
account.networkingClient = netClient`;

You can configure the Auth0 class with a `NetworkingClient` to customize how the SDK makes requests. The default client supports custom timeout values, headers sent on all requests, and request/response logging for non-production debugging. For more advanced use cases, you can provide your own `NetworkingClient` implementation.

## Configure timeouts

<AuthCodeBlock children={codeExample1} language="kotlin" />

## Configure logging

<AuthCodeBlock children={codeExample2} language="kotlin" />

You can also provide a custom logger to control where logs are written.

<AuthCodeBlock children={codeExample5} language="kotlin" />

## Set additional headers for all requests

<AuthCodeBlock children={codeExample3} language="kotlin" />

## Configure advanced networking

For advanced networking configuration, provide a custom implementation of `NetworkingClient`. This is useful when you want to reuse your own networking client, configure a proxy, and more.

<AuthCodeBlock children={codeExample4} language="kotlin" />
