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
| Field | Type | Description |
|---|---|---|
email | String | Email address of the user. Empty string if not available. |
name | String | Display name of the user. Empty string if not available. |
profileImage | String | URL of the user's profile image. Empty string if not available. |
authConnectionId | String | The auth connection ID (verifier name) used to log in. |
groupedAuthConnectionId | String | The grouped auth connection ID if aggregate verifiers are used. Empty string if not applicable. |
userId | String | The user's unique ID within the auth connection (e.g. email for email-based, sub for OAuth). |
authConnection | String | The auth connection type used (e.g. "google", "custom"). |
dappShare | String | DApp share for custom verifiers. Empty string for default verifiers. |
idToken | String | JWT issued by Web3Auth after authentication. |
oAuthIdToken | String | JWT issued by the OAuth provider. Only present for custom verifiers. |
oAuthAccessToken | String | Access token issued by the OAuth provider. Only present for custom verifiers. |
isMfaEnabled | Boolean? | 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
)