authenticate

fun authenticate(route: ERROR CLASS: Symbol not found for Route??, response: ERROR CLASS: Symbol not found for Response): ERROR CLASS: Symbol not found for Request??

Called by OkHttp whenever a response with HTTP 401 is received.

Inspects the failed request to confirm it was using Bearer authentication, then attempts a single token refresh. Returns the original request (unchanged) so that OkHttp re-runs the application interceptors — io.rekast.sdk.network.interceptor.auth.AccessTokenInterceptor will pick up the new token from CredentialStorage and attach the correct header.

Returns null to give up without retrying in any of the following cases:

  • The original request did not use Bearer auth.

  • More than one prior response exists for this request (retry limit reached).

  • The API key is unavailable (cannot form a Basic Auth token-exchange request).

  • The product type or subscription key cannot be extracted from the original request.

  • The Bearer token endpoint itself returns a non-2xx response.

OAuth2 token refresh failure is non-fatal — the original request is still retried with the refreshed Bearer token even if the OAuth2 refresh fails.

Return

The original request to trigger a retry, or null to propagate the 401 to the caller.

Parameters

route

The route for the failed request (unused but required by the interface).

response

The 401 response received from the server.