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 operationstopic. To use an app that is authorized by a user, follow the Associate a user with a miniapp containerstep to associate the app user with the container to obtain more features.
User's Personal Information Authorization
The WindVane miniapp container provides an interface for requesting authorization from users. You must implement the specific authorization logic in the superapp.
Use
EMASServiceManagerto registerEMASMiniappUserAuthService.In the
getAuthCodemethod of theEMASMiniappUserAuthServiceImplimplementation class, implement the specific authorization business logic and UI interaction. You can design the authorization dialog box based on your visual requirements.In the
getAuthCodemethod of theEMASMiniappUserAuthServiceImplimplementation class, useEMASMiniappUserAuthSuccessBlockto return the authorization result to the miniapp container. Then, the miniapp container returns the result to the miniapp.
Sample code:
// Register the authorization implementation class.
[[EMASServiceManager sharedInstance] registerServiceProtocol:@"EMASMiniappUserAuthService" IMPClass:@"EMASMiniappUserAuthServiceImpl" target:nil];
@implementation EMASMiniappUserAuthServiceImpl
- (void)getAuthCode:(NSString *)appId scopes:(NSArray *)scopes successBlock:(EMASMiniappUserAuthSuccessBlock)successBlock failureBlock:(EMASMiniappUserAuthFailureBlock)failureBlock {
// Implement the process of granting permissions on user resources to the miniapp.
}
@end
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.