For AI agents: a documentation index is available at /llms.txt. A markdown version of this page is available at the same URL with .md appended (or via Accept: text/markdown).
Skip to main content

Refresh the session

Use the refreshSession method to re-authorize the current session without asking the user to sign in again. It returns a CompletableFuture<Web3AuthResponse> with the refreshed session data.

If re-authorization fails, the SDK clears the stored Auth tokens and the in-memory session, and the future completes exceptionally. Prompt the user to sign in again in that case.

Usage​

web3Auth.refreshSession().whenComplete { response, error ->
if (error == null) {
// Session refreshed
val privateKey = web3Auth.getPrivateKey()
} else {
// Session could not be refreshed. Show the sign-in screen.
Log.d("MainActivity_Web3Auth", error.message ?: "Unable to refresh session")
}
}
note

enableMFA() and manageMFA() call refreshSession() internally before opening the MFA flow, so you don't need to call it yourself before those methods.

On this page