English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Log in as a user

Last Updated on : 2022-01-07 07:03:32download

The class TYUserManager provides methods to log in as a user and keep the session.

Note : Currently, the SDK cannot be used to register a user. All registration processes are finished on the platform. You must manually add users to your project to log in successfully. The specific operation can refer to the document Manage User Account.

Parameter Description

Parameter name Type Required Description
userName String true Username
password String true Password

TokenBean Description

Parameter name Type Description
uid String User ID
accessToken String Access token
refreshToken String Refresh token
expire Integer Expiration time

Code example

TYUserManager.getUserBusiness().login(userName, password, new ResultListener<BizResponse>() {
    @Override
    public void onFailure(String errorCode, String errorMsg) {
        
    }

    @Override
    public void onSuccess(BizResponse bizResponse) {
        String convertString = JsonParser.convertUnderLineToHump(bizResponse.getResult().toString());
        TokenBean tokenBean = JsonParser.parseAny(convertString, TokenBean.class);
        // Store Token
        AccessTokenManager.getAccessTokenRepository().storeInfo(tokenBean, bizResponse.getT());
    }
});