Skip to main content

Auth API

Auth API

Login(onSuccess, onFail, timeout)

Performs user login.

Parameters:

ParameterTypeRequiredDescription
onSuccessAction<LoginResult>-Success callback
onFailAction<string>-Failure callback
timeoutint-Timeout (ms)

Success Response (LoginResult):

FieldTypeDescription
codestringLogin code (for server authentication)
userIdstringUnique user ID
userInfoPayloadstringVerifiable user info payload (URL-encoded query string)
userInfoSignaturestringSignature for userInfoPayload
errMsgstringResult message
errCodeintError 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 containing attribute, authDate, gameUserId, name, profileImageUrl
  • userInfoSignature: Signature over userInfoPayload

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:

ParameterTypeRequiredDescription
onSuccessAction<CheckSessionResult>-Callback when session is valid
onFailAction<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:

ParameterTypeRequiredDescription
onSuccessAction<GetUserInfoResult>-Success callback
onFailAction<string>-Failure callback

Success Response (GetUserInfoResult):

FieldTypeDescription
userInfo.nickNamestringNickname
userInfo.avatarUrlstringAvatar URL
userInfoPayloadstringVerifiable user info payload (URL-encoded query string)
userInfoSignaturestringSignature 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)
);