bluesky_queueserver_api.http.REManagerAPI.api_scopes

REManagerAPI.api_scopes(*, token=None, api_key=None)

Returns API scopes for an authorized user. Authorization is performed using the default authorization key (set using REManagerAPI.set_authorization_key() or as a result of login) or an access token or an API key passed as parameters. The API returns the exact list scopes that is currently used by the server for validating access permissions for the token or the API key used for authorization. In addition, the API returns a list of roles for the authorized user. The returned scopes are always a subset of combined scopes of the roles.

Parameters:
token, api_key: str or None, optional

Access token or an API key. The parameters are mutually exclusive: the API fails if both parameters are not None. A token or an API key overrides the default authentication key. Default: None.

Returns:
dict

Dictionary keys: roles, scopes. See the example in the API description.

Raises:
RequestParameterError

Incorrect or insufficient parameters in the API call.

HTTPRequestError, HTTPClientError, HTTPServerError

Error while sending and processing HTTP request.

Examples

Log into the server and get the scopes:

RM.login("bob", password="bob_password")
result = RM.whoami()

# {'roles': ['admin', 'expert'],
#  'scopes': ['admin:apikeys',
#             'admin:metrics',
#             'admin:read:principals',
#             'read:config',
#             'read:console',
#             'read:history',
#             'read:lock',
#             'read:monitor',
#             'read:queue',
#             'read:resources',
#             'read:status',
#             'read:testing',
#             'user:apikeys',
#             'write:config',
#             'write:execute',
#             'write:history:edit',
#             'write:lock',
#             'write:manager:control',
#             'write:permissions',
#             'write:plan:control',
#             'write:queue:control',
#             'write:queue:edit',
#             'write:scripts']}