# Permission

Some interfaces need to be authorized by the user before they can be called. We divide these interfaces into multiple scopes according to the scope of use. The user chooses to authorize scope. When authorized to a scope, all the corresponding interfaces can be used directly.

When this type of interface is called: -If the user has not accepted or rejected this permission, a pop-up window will pop up to ask the user, and the user can call the interface after clicking on the consent; -If the user is authorized, he can directly call the interface; -If the user has refused the authorization, the pop-up window will not appear, but directly enter the interface fail callback. **Please allow the developer to be compatible with the scenario where the user refuses to authorize. **

# Get user authorization settings

Developers can use wx.getSetting to get the user's current authorization status.

# Open the settings interface

The user can control the authorization status of the applet in the applet settings interface ("upper right corner"-"about"-"upper right corner"-"settings").

Developers can call wx.openSetting to open the setting interface and guide users to enable authorization.

# Initiate an authorization request in advance

Developers can use wx.authorize to initiate an authorization request to the user before calling the authorization API.

# scope list

scope Corresponding interface Description
scope.userInfo wx.getUserInfo User Information
scope.userLocation wx.getLocation geographic location
scope.werun wx.getWeRunData WeChat movement steps
scope.writePhotosAlbum wx.saveImageToPhotosAlbum Save to Album

# Authorization validity period

Once the user explicitly agrees or rejects the authorization, the authorization relationship will be recorded in the background until the user actively deletes the applet.

# Best Practices

Only when the authorization interface really needs to be used, an authorization application is initiated to the user, and the reason for using the function is clearly stated in the authorization application.

# Precautions

  1. wx.authorize({scope: "scope.userInfo"}), the authorization window will not pop up, please use wx.createUserInfoButton
  2. When you need to authorize scope.userLocation, you must [Configuration/app#permission] ((configuration/app#permission)).
点击咨询小助手