Skip to main content

Retrieve user information

You can use the getUserInfo method to retrieve various details about the user, such as their login type, whether multi-factor authentication (MFA) is enabled, profile image, name, and other relevant information.

note

getUserInfo() throws an Error with code NOUSERFOUND when no active session exists. Always call it after initialize() completes and only when getPrivateKey() returns a non-empty string.

Usage

val userInfo = web3Auth.getUserInfo()

UserInfo Fields

FieldTypeDescription
emailStringEmail address of the user. Empty string if not available.
nameStringDisplay name of the user. Empty string if not available.
profileImageStringURL of the user's profile image. Empty string if not available.
authConnectionIdStringThe auth connection ID (verifier name) used to log in.
groupedAuthConnectionIdStringThe grouped auth connection ID if aggregate verifiers are used. Empty string if not applicable.
userIdStringThe user's unique ID within the auth connection (e.g. email for email-based, sub for OAuth).
authConnectionStringThe auth connection type used (e.g. "google", "custom").
dappShareStringDApp share for custom verifiers. Empty string for default verifiers.
idTokenStringJWT issued by Web3Auth after authentication.
oAuthIdTokenStringJWT issued by the OAuth provider. Only present for custom verifiers.
oAuthAccessTokenStringAccess token issued by the OAuth provider. Only present for custom verifiers.
isMfaEnabledBoolean?Whether the user has MFA enabled. null if the information is not available in the session.

Interface

data class UserInfo(
var email: String = "",
var name: String = "",
var profileImage: String = "",
var groupedAuthConnectionId: String = "",
var authConnectionId: String = "",
var userId: String = "",
var authConnection: String = "",
var dappShare: String = "",
var idToken: String = "",
var oAuthIdToken: String = "",
var oAuthAccessToken: String = "",
var isMfaEnabled: Boolean? = null
)