tencent cloud

Authorization Settings
Last updated: 2025-08-29 18:33:06
Authorization Settings
Last updated: 2025-08-29 18:33:06

Settings

AuthSetting

Feature description:User authorization setting information. For all scopes, see Scope list.
Parameter and description:
Property
Description
boolean scope.userLocation
Whether location access is authorized. The corresponding APIs are wx.getLocation and wx.chooseLocation.
boolean scope.writePhotosAlbum
Whether the user has authorized saving images to their photo album. Corresponds to wx.saveImageToPhotosAlbum.
boolean scope.camera
Whether camera access is authorized. Corresponds to the <camera /> component.

getSetting

This API is called using wx.getSetting(Object object).
Feature description:Gets the current settings of the user.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure)
object.success callback function parameter:Object res.
Property
Type
Description
authSetting
AuthSetting
User authorization result.
Example:
wx.getSetting({
success(res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})

openSetting

This API is called using wx.openSetting(Object object).
Feature description:This API is used to open the mini program settings page in the superapp, returning the user's settings operation results. After the user taps, they can navigate to the settings page to manage authorization information.
Parameter and description: Object object.
Property
Type
Default value
‍Required
Description
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure)
object.success callback function parameter:Object res.
Property
Type
Description
authSetting
AuthSetting
User authorization result.
Example:
wx.openSetting({
success(res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})
wx.openSetting({
success (res) {
console.log(res.authSetting)
// res.authSetting = {
// "scope.userInfo": true,
// "scope.userLocation": true
// }
}
})

Authorization

authorize

This API is called using wx.authorize(Object object).
Feature description:This API is used to initiate an authorization request to the user in advance. After this API is called, a window will pop up, asking the user whether they agree to authorize the mini program to use a certain feature or access certain user data. However, the corresponding APIs are not actually called. If the user has previously granted authorization, the pop-up will not appear, and it will directly return a success response.
Parameter and description:Object object.
Property
Type
Default value
‍Required
Description
scope
string
-
True
Scopes requiring authorization. For more information, see Scope list.
success
function
-
False
Callback function for successful API calls.
fail
function
-
False
Callback function for failed API calls.
complete
function
-
False
Callback function executed after API call ends (regardless of success or failure)
Example:
// You can query whether the user has authorized the scope of "scope.record" using wx.getSetting.
wx.getSetting({
success(res) {
if (!res.authSetting['scope.record']) {
wx.authorize({
scope: 'scope.record',
success() {
// Once the user has granted permission for the mini program to use the recording feature, subsequent calls to the wx.startRecord API will not prompt the user for permission again.
wx.startRecord()
}
})
}
}
})







Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback