All Products
Search
Document Center

SuperApp:wv.authorize

Last Updated:May 27, 2026

Requests user authorization for device-related JavaScript APIs listed in the Scope list. Prompts the user to grant permission without calling the target API. If already authorized, skips the prompt and invokes the success callback directly.

Request parameters

Parameter

Type

Required

Description

scope

String

Yes

Permission scope to request.

success

Function

No

Callback invoked on successful authorization.

fail

Function

No

Callback invoked on failed authorization.

Scope list

Scope

Description

APIs

location

Geographical location

WVLocation.getLocation, WVLocation.searchLocation

camera

Camera

WVScan.scan

bluetooth

Bluetooth

All methods of WVBluetooth

album

Album

WVCamera, WVVideo.chooseVideo

contacts

Contacts

All methods of WVContacts

microphone

Microphone

WVMotion.listenBlow, WVMotion.stopListenBlow

file

File

All methods of WVFile, WVImage.saveImage, WVVideo.saveVideoToPhotosAlbum

call

Phone call

WVCall.dial, WVCall.call

vibrate

Vibration

WVMotion.vibrate

screen

Screen capture

WVScreenCapture.capture

Response parameters

The success callback receives an object with these attributes:

Attribute

Type

Description

successScope

JSONObject

Scopes the user authorized.

msg

String

Error message on failure.

The fail callback receives an object with the error in msg:

Error message

Description

Solution

You need to configure the authorization switch to apply for authorization

Authorization switch is not enabled.

Verify the authorization switch is configured during container initialization.

Parameter parsing exception

Request parameters cannot be parsed.

Verify request parameter format.

Authorization scope cannot be empty

The scope parameter is null.

Check the scope parameter.

User not bound

The UserId is not registered in the container.

Verify container user information includes a UserId.

User refuses authorization request

The user denied the authorization request.

Prompt the user with a clear reason to grant authorization.

The authorization you requested does not exist. Please check the parameters

The provided scope is not a valid value.

Verify the scope value against the Scope list.

Sample code

window.WindVane.call('wv', 'getSetting', {}, function(res) {
    if (!res.authSetting['location']) {
      	window.WindVane.call('wv', 'authorize', {scope: 'location'}, function(res) {
          	if (res.successScope['location']) {
              	alert('success authorize location');
              	// Call the required JavaScript API.
            }
        }, function(e) {
          	alert('failure:' + JSON.stringify(e));
        })
    } else {
      	alert('success authorize location');
    }
}, function(e) {
    alert('failure:' + JSON.stringify(e));
});