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 |
userInfoPayload | string | Verifiable user info payload (URL-encoded query string) |
userInfoSignature | string | Signature for userInfoPayload |
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
// Verify on game server using shared secret
SendToGameServer(result.userInfoPayload, result.userInfoSignature);
},
onFail: (err) => Debug.LogError("Login failed: " + err),
timeout: 10000 // Optional: timeout (ms)
);
User Info Credential (userInfoPayload / userInfoSignature)
Signed user info that the game server can verify on its own using only a shared secret key — no server-to-server call required.
userInfoPayload: URL-encoded query string containingattribute,authDate,gameUserId,name,profileImageUrluserInfoSignature: Signature overuserInfoPayload
After signature verification, the game server may apply its own expiry policy based on authDate (unix timestamp 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(onSuccess, onFail)
Retrieves user profile information. Returns the user profile alongside the user info credential (userInfoPayload/userInfoSignature) for game server verification — same value as the credential issued at login.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
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 |
userInfoPayload | string | Verifiable user info payload (URL-encoded query string) |
userInfoSignature | string | Signature for userInfoPayload |
TudadaSDK.Instance.GetUserInfo(
onSuccess: (result) => {
Debug.Log("Nickname: " + result.userInfo.nickName);
Debug.Log("Avatar: " + result.userInfo.avatarUrl);
// Verify on game server
SendToGameServer(result.userInfoPayload, result.userInfoSignature);
},
onFail: (err) => Debug.LogError("Query failed: " + err)
);