All Products
Search
Document Center

SuperApp:Implement user personal information authorization for WindVane miniapps

Last Updated:Jan 17, 2025

WindVane miniapps support authorization from users. This topic describes how to implement the authorization logic. For information about the authorization process, see the "Authorize a merchant to call an API operation" section of the Authorization mechanism when calling API operations. To use an app that is authorized by a user, follow the Associate a user with a miniapp container to associate the app user with the container to obtain more features. 

Request authorization from users

The WindVane miniapp container provides an interface for requesting authorization from users. You must implement the specific authorization logic in the superapp.

  1. Use ServiceManager to register IMiniAppUserAuthService.

  2. In the getAuthCode method of the IMiniAppUserAuthService implementation class, implement the specific authorization business logic and UI interaction. You can design the authorization dialog box based on your visual requirements.

  3. In the getAuthCode method of the IMiniAppUserAuthService implementation class, use IUserAuthCallback to return the authorization result to the miniapp container. Then, the miniapp container returns the result to the miniapp.

Sample code:

ServiceManager.getInstance().registerService(IMiniAppUserAuthService.class.getName(), new IMiniAppUserAuthService() {
    @Override
    public void getAuthCode(Context context, String appId, List<String> scopes, IUserAuthCallback callback) {
				// Implement the process of granting permissions on user resources to the miniapp. 
    }
});

Scopes indicate the specific permissions that are granted to the miniapp. For information about the pre-defined scopes, see Authorization description. You can add scopes based on your business requirements.