Auth API
Auth API
login(options)
Performs user login and issues an authentication code.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
timeout | number | - | Timeout (ms) |
success | function | - | Success callback |
fail | function | - | Failure callback |
complete | function | - | Completion callback |
Success Response:
| Field | Type | Description |
|---|---|---|
code | string | User login code (for server authentication) |
userId | string | User unique ID |
userInfoPayload | string | Verifiable user info payload (URL-encoded query string) |
userInfoSignature | string | Signature for userInfoPayload |
errMsg | string | Result message |
TudadaSDK.login({
timeout: 10000,
success: (res) => {
console.log('Login code:', res.code);
console.log('User ID:', res.userId);
// Send code to server to create session
// Verify on game server using shared secret
sendToGameServer({
payload: res.userInfoPayload,
signature: res.userInfoSignature,
});
},
fail: (err) => console.error('Login failed:', err.errMsg),
});
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(options)
Checks the validity of the current session.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
success | function | - | Success callback (session is valid) |
fail | function | - | Failure callback (session expired) |
complete | function | - | Completion callback |
TudadaSDK.checkSession({
success: (res) => console.log('Session valid'),
fail: () => {
console.log('Session expired, re-login required');
TudadaSDK.login({ ... });
},
});
getUserInfo(options)
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.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
lang | 'KO' | - | Response language |
success | function | - | Success callback |
fail | function | - | Failure callback |
complete | function | - | Completion callback |
Success Response:
| Field | Type | Description |
|---|---|---|
userInfo.nickName | string | Nickname |
userInfo.avatarUrl | string | Avatar image URL |
userInfoPayload | string | Verifiable user info payload (URL-encoded query string) |
userInfoSignature | string | Signature for userInfoPayload |
TudadaSDK.getUserInfo({
success: (res) => {
console.log('Nickname:', res.userInfo.nickName);
console.log('Avatar:', res.userInfo.avatarUrl);
// Verify on game server
sendToGameServer({
payload: res.userInfoPayload,
signature: res.userInfoSignature,
});
},
});