Checks if the current client has access to a specific JSBridge API method.
The name of the SDK module to check access for (e.g., 'CameraModule').
The method name within the module to check access for (e.g., 'scanQRCode').
This method can return the following status_code values:
200 (OK): Access check completed successfully. The result contains HasAccessToResult.400 (Bad Request): Invalid request parameters.424 (Failed Dependency): Dependency error occurred while checking access.500 (Internal Server Error): An unexpected error occurred.501 (Not Implemented): Requires Grab app environment.import { ScopeModule, isSuccess, isError } from '@grabjs/superapp-sdk';
// Initialize the scope module
const scope = new ScopeModule();
// Check access to CameraModule.scanQRCode
const response = await scope.hasAccessTo('CameraModule', 'scanQRCode');
// Handle the response
if (isSuccess(response)) {
console.log('Has access:', response.result);
} else if (isError(response)) {
console.error(`Error ${response.status_code}: ${response.error}`);
} else {
console.error('Unhandled response');
}
Requests to reload the consented OAuth scopes for the current client. This refreshes the permissions from the server.
This method can return the following status_code values:
204 (No Content): Scopes reloaded successfully.424 (Failed Dependency): Dependency error occurred while reloading scopes.500 (Internal Server Error): An unexpected error occurred.501 (Not Implemented): Requires Grab app environment.import { ScopeModule, isSuccess, isError } from '@grabjs/superapp-sdk';
// Initialize the scope module
const scope = new ScopeModule();
// Reload scopes
const response = await scope.reloadScopes();
// Handle the response
if (isSuccess(response)) {
console.log('Scopes reloaded successfully');
} else if (isError(response)) {
console.error(`Error ${response.status_code}: ${response.error}`);
} else {
console.error('Unhandled response');
}
SDK module for checking and refreshing API access permissions via
JSBridge.Remarks
Manages OAuth scope permissions, allowing the MiniApp to check access rights and reload scopes from the server. This code must run on the Grab SuperApp's WebView to function correctly.
Example
ES Module:
Example
CDN (UMD):