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 |
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
},
fail: (err) => console.error('Login failed:', err.errMsg),
});
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.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
withCredentials | boolean | - | Whether to include encrypted data |
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 |
encryptedData | string | Encrypted data (when using withCredentials) |
iv | string | Encryption initialization vector (when using withCredentials) |
signature | string | Signature (when using withCredentials) |
rawData | string | Raw data (when using withCredentials) |
TudadaSDK.getUserInfo({
success: (res) => {
console.log('Nickname:', res.userInfo.nickName);
console.log('Avatar:', res.userInfo.avatarUrl);
},
});
// With encrypted data
TudadaSDK.getUserInfo({
withCredentials: true,
success: (res) => {
// Send encryptedData, iv to server for verification
sendToServer(res.encryptedData, res.iv);
},
});