Open Capabilities
my.getOpenUserInfo
Get basic user information with user consent.
Request access to the user’s basic profile information. This API must be triggered by a button tap — it cannot be called directly on page load.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Get basic user information with user consent.
<button> component with open-type="getAuthorize" and scope="userInfo". Calling it outside of that interaction will fail. To obtain the userId specifically, use my.getAuthCode instead.| Property | Type | Required | Description |
|---|---|---|---|
| success | Function | No | Callback with user info |
| fail | Function | No | Callback on failure |
| complete | Function | No | Callback that always executes |
| Property | Type | Description |
|---|---|---|
| code | String | Result code |
| msg | String | Result message |
| avatar | String | Profile image URL (max 2048 bytes) |
| nickName | String | Display name (max 128 bytes) |
| gender | String | m for male, f for female |
| countryCode | String | ISO 3166-1 alpha-2 country code (e.g. IT) |
| province | String | User’s province |
| city | String | User’s city |
| Code | Meaning |
|---|---|
10000 | Success |
40006 | Insufficient permissions |
// In your AXML template:
// <button open-type="getAuthorize" scope="userInfo" onGetAuthorize="onGetAuthorize">Get User Info</button>
onGetAuthorize(res) {
my.getOpenUserInfo({
success: (res) => {
const userInfo = JSON.parse(res.response).response;
console.log('Nickname:', userInfo.nickName);
console.log('Avatar:', userInfo.avatar);
},
fail: (err) => {
console.error('Failed to get user info:', err);
}
});
}