sud.login
javascript
sud.login(object)Gets a single-use temporary login credential, code. Send it to your game server (Game SVR) to complete login.
Parameters
Object object
| Property | Type | Required | Description |
|---|---|---|---|
| success | function | No | Callback invoked when the call succeeds |
| fail | function | No | Callback invoked when the call fails |
| complete | function | No | Callback invoked when the call finishes, on either success or failure |
Callback Parameters
success
| Property | Type | Description |
|---|---|---|
| code | string | Single-use temporary login credential |
fail
| Property | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error message |
complete
Invoked after success or fail, without arguments.
Usage Notes
- Use
codeonly once and submit it to your game server promptly and unchanged. Do not use it as a persistent login credential. - Manage session keys on the game server. Do not store them on the client or write them to logs.
- See Session Management for server integration and Login and User Information Flow for retrieving user data after login.
Example
javascript
sud.login({
success(res) {
// Call your game server's login endpoint here and submit res.code.
// Update the game state using the server's login result.
},
fail(err) {
console.error('Login failed', err.errCode, err.errMsg);
},
complete() {
// Dismiss the login progress indicator.
},
});