Auth API
Auth API
Login(onSuccess, onFail, timeout)
Performs user login.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
onSuccess | Action<LoginResult> | - | Success callback |
onFail | Action<string> | - | Failure callback |
timeout | int | - | Timeout (ms) |
Success Response (LoginResult):
| Field | Type | Description |
|---|---|---|
code | string | Login code (for server authentication) |
userId | string | Unique user ID |
errMsg | string | Result message |
errCode | int | Error code |
TudadaSDK.Instance.Login(
onSuccess: (result) => {
Debug.Log("Login code: " + result.code);
Debug.Log("User ID: " + result.userId);
// Send result.code to server to create session
},
onFail: (err) => Debug.LogError("Login failed: " + err),
timeout: 10000 // Optional: timeout (ms)
);
CheckSession(onSuccess, onFail)
Checks whether the session is valid.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
onSuccess | Action<CheckSessionResult> | - | Callback when session is valid |
onFail | Action<string> | - | Callback when session has expired |
TudadaSDK.Instance.CheckSession(
onSuccess: (result) => Debug.Log("Session valid"),
onFail: (err) => {
Debug.Log("Session expired, re-login required");
TudadaSDK.Instance.Login(...);
}
);
GetUserInfo(withCredentials, onSuccess, onFail)
Retrieves user profile information.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
withCredentials | bool | - | Whether to include encrypted data |
onSuccess | Action<GetUserInfoResult> | - | Success callback |
onFail | Action<string> | - | Failure callback |
Success Response (GetUserInfoResult):
| Field | Type | Description |
|---|---|---|
userInfo.nickName | string | Nickname |
userInfo.avatarUrl | string | Avatar URL |
encryptedData | string | Encrypted data |
iv | string | Encryption vector |
signature | string | Signature |
TudadaSDK.Instance.GetUserInfo(
withCredentials: false, // Whether to include encrypted data
onSuccess: (result) => {
Debug.Log("Nickname: " + result.userInfo.nickName);
Debug.Log("Avatar: " + result.userInfo.avatarUrl);
},
onFail: (err) => Debug.LogError("Query failed: " + err)
);