sud.getUserProfile
javascript
sud.getUserProfile(object)Gets user profile data, including basic information and encrypted data. Use basic information for display and send encrypted data unchanged to your game server for processing.
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 |
|---|---|---|
| userInfo | Object | Basic user information; see the fields below |
| rawData | string | Original data string required for verification |
| encryptedData | string | Encrypted user data |
| iv | string | Parameter required for server-side decryption |
| signature | string | Signature required for server-side verification |
userInfo
| Property | Type | Description |
|---|---|---|
| nickname | string | User nickname |
| avatar | string | User avatar |
| avatarUrl | string | Remote URL of the user avatar |
fail
| Property | Type | Description |
|---|---|---|
| errCode | number | Error code |
| errMsg | string | Error message |
complete
Invoked after success or fail, without arguments.
Usage Notes
- First complete login with sud.login and have your game server establish the current user's session.
- Send
rawData,encryptedData,iv, andsignatureunchanged to your game server. Do not modify their contents or re-serializerawData. - Do not decrypt the data or store server keys on the game client. See User Information Guide for server integration requirements.
- Use sud.getUserInfo if you only need the nickname and avatar.
Example
javascript
sud.getUserProfile({
success(res) {
const profileData = {
rawData: res.rawData,
encryptedData: res.encryptedData,
iv: res.iv,
signature: res.signature,
};
// Send profileData unchanged to your game server using your request API.
// Read basic information from res.userInfo.
},
fail(err) {
console.error('Failed to get user profile', err.errCode, err.errMsg);
},
});