Skip to content

Permissions

The permissions module grants or denies browser permissions without user dialogs. For full usage examples, see Permissions.

Methods

set_permission

Grant, deny, or reset a browser permission:

await client.permissions.set_permission(
    descriptor={"name": "geolocation"},
    state="granted",
    contexts=["context-id-1"],
)

Reference

PermissionsModule

Module for managing browser permissions.

Commands
  • set_permission — set a permission state (granted, denied, prompt)
Example

await client.permissions.set_permission( descriptor={"name": "geolocation"}, state="granted", contexts=[ctx_id], )

Source code in bidiwave/modules/permissions.py
class PermissionsModule:
    """Module for managing browser permissions.

    Commands:
        - set_permission — set a permission state (granted, denied, prompt)

    Example:
        await client.permissions.set_permission(
            descriptor={"name": "geolocation"},
            state="granted",
            contexts=[ctx_id],
        )
    """

    def __init__(self, connection: Connection) -> None:
        self._connection = connection

    async def set_permission(
        self,
        descriptor: dict[str, Any],
        state: Literal["granted", "denied", "prompt"],
        contexts: list[str] | None = None,
        origin: str | None = None,
    ) -> None:
        """Sets the state of a browser permission.

        Args:
            descriptor: Permission descriptor (e.g. {"name": "geolocation"}).
            state: Permission state to set.
            contexts: Context IDs to apply to. None = all.
            origin: Origin to apply the permission to. Required if no contexts.
        """
        params: dict[str, Any] = {
            "descriptor": descriptor,
            "state": state,
        }
        if contexts is not None:
            params["contexts"] = contexts
        if origin is not None:
            params["origin"] = origin
        await self._connection.send_command(PERMISSIONS_SET, params)

set_permission async

set_permission(descriptor: dict[str, Any], state: Literal['granted', 'denied', 'prompt'], contexts: list[str] | None = None, origin: str | None = None) -> None

Sets the state of a browser permission.

Parameters:

Name Type Description Default
descriptor dict[str, Any]

Permission descriptor (e.g. {"name": "geolocation"}).

required
state Literal['granted', 'denied', 'prompt']

Permission state to set.

required
contexts list[str] | None

Context IDs to apply to. None = all.

None
origin str | None

Origin to apply the permission to. Required if no contexts.

None
Source code in bidiwave/modules/permissions.py
async def set_permission(
    self,
    descriptor: dict[str, Any],
    state: Literal["granted", "denied", "prompt"],
    contexts: list[str] | None = None,
    origin: str | None = None,
) -> None:
    """Sets the state of a browser permission.

    Args:
        descriptor: Permission descriptor (e.g. {"name": "geolocation"}).
        state: Permission state to set.
        contexts: Context IDs to apply to. None = all.
        origin: Origin to apply the permission to. Required if no contexts.
    """
    params: dict[str, Any] = {
        "descriptor": descriptor,
        "state": state,
    }
    if contexts is not None:
        params["contexts"] = contexts
    if origin is not None:
        params["origin"] = origin
    await self._connection.send_command(PERMISSIONS_SET, params)