User Info

Ability to get user details like their email addresses directly from the client API and the SDKs is on our roadmap. You can keep track of the issue here: https://github.com/authgear/authgear-server/issues/260

UserInfo

At the meantime, the userInfo object is returned from calling fetch user info function which contains a unique identifier of the user.

Key

Type

Description

isAnonymous

boolean

Indicate if the user is anonymous, i.e. no identity or authenticator is provided

isVerified

boolean

Indicate if the user completed the verification requirement

sub

string

Unique identifier of the user in your Authgear project

JavaScript
iOS
Android
JavaScript
try{
const userInfo = await authgear.fetchUserInfo()
} catch(e) {
// failed to fetch user info
// the refresh token maybe expired or revoked
}
iOS
authgear.fetchUserInfo { userInfoResult in
// sessionState is now up to date
// it will change to .noSession if the session is invalid
let sessionState = authgear.sessionState
switch userInfoResult {
case let .success(userInfo):
// read the userInfo if needed
case let .failure(error):
// failed to fetch user info
// the refresh token maybe expired or revoked
}
Android
authgear.fetchUserInfo(new OnFetchUserInfoListener() {
@Override
public void onFetchedUserInfo(@NonNull UserInfo userInfo) {
// sessionState is now up to date
// read the userInfo if needed
}
@Override
public void onFetchingUserInfoFailed(@NonNull Throwable throwable) {
// sessionState is now up to date
// it will change to NO_SESSION if the session is invalid
}
});