Open edX AuthZ

raw JSON →
1.15.0 verified Fri May 01 auth: no python

Open edX AuthZ provides the architecture and foundations of the authorization framework for the Open edX platform. Currently at version 1.15.0 (requires Python >=3.12), it offers a REST API for managing roles, scopes, and role assignments. The library is actively maintained by the Open edX community with regular releases.

pip install openedx-authz
error ModuleNotFoundError: No module named 'openedx_authz'
cause Package not installed or installed in a different environment.
fix
Run 'pip install openedx-authz' and ensure you are in the correct virtual environment.
error ImportError: cannot import name 'RoleAssignmentAPIClient' from 'openedx_authz'
cause Incorrect import path; the class is under openedx_authz.api.v1.
fix
Use 'from openedx_authz.api.v1 import RoleAssignmentAPIClient'.
error TypeError: list_role_assignments() takes 1 positional argument but 2 were given
cause Passing filters as positional arguments is not allowed since v1.10.0.
fix
Use keyword arguments: Client.list_role_assignments(org='my_org') instead of Client.list_role_assignments('my_org').
breaking Python 3.12 is required as of v1.15.0. Older Python versions will cause import errors.
fix Upgrade Python to 3.12 or later.
gotcha The API client methods (e.g., list_role_assignments) now require keyword arguments for filters since v1.10.0. Passing positional arguments will result in a TypeError.
fix Use keyword arguments: Client.list_role_assignments(org='my_org') instead of Client.list_role_assignments('my_org').
deprecated The PUT /api/authz/v1/roles/users/ endpoint now supports bulk scopes as of v1.11.0; the old single-scope format is deprecated.
fix Update payload to include scopes as a list: {"scopes": ["scope1", "scope2"]}.

Initialize the REST API client and fetch role assignments.

from openedx_authz.api.v1 import RoleAssignmentAPIClient
Client = RoleAssignmentAPIClient(base_url='http://localhost:8000', api_key=os.environ.get('API_KEY', ''))
# Example: list role assignments
assignments = Client.list_role_assignments()
print(assignments)