bluesky_queueserver_api.http.REManagerAPI.session_revoke¶
- REManagerAPI.session_revoke(*, session_uid, token=None, api_key=None)¶
Revoke session for an authorized user. If the session is revoked, the respective refresh token can no longer be used to refresh session. Access tokens and API keys will continue working. By default the API request is authorized using the default authorization key (set using
set_authorization_key()
or as a result of login). A token or an API key passed as a parameter override the default authorization key, which allows to revoke sessions for different users without changing the default authorization key (without logging out).- Parameters:
- session_uid: str
Full session UID. Session UID may be obtained from results returned by
REManagerAPI.whoami()
orREManagerAPI.principal_info()
.- 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
Returns the dictionary
{'success': True, 'msg': ''}
in case of success.
- 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, find UID of a session and revoke the session:
RM.login("bob", password="bob_password") result = RM.whoami() # {'uuid': '352cae89-7e94-45be-a405-c39099ebe515', # 'type': 'user', # 'identities': [ # {'id': 'bob', # 'provider': 'toy', # 'latest_login': '2022-10-02T02:47:57'}], # 'api_keys': [], # 'sessions': [{'uuid': 'e544d4b6-4750-43c3-8ba0-b7e9aedd2045', # 'expiration_time': '2023-10-01T19:28:15', # 'revoked': False}, # {'uuid': '66ee49c1-32b4-4778-8502-205e35151736', # 'expiration_time': '2023-10-01T19:30:03', # 'revoked': False}, # ..................................................... # {'uuid': 'c41d2f01-607e-49c0-9b3e-a93c383330c0', # 'expiration_time': '2023-10-02T02:47:57', # 'revoked': False}], # 'latest_activity': '2022-10-02T02:47:57', # 'roles': [], # 'scopes': [], # 'api_key_scopes': None} # Let's revoke session "e544d4b6-4750-43c3-8ba0-b7e9aedd2045" RM.session_revoke(session_uid="e544d4b6-4750-43c3-8ba0-b7e9aedd2045") result = RM.whoami() # NOTE: the session is now labeled as revoked ("revoked": True) # {'uuid': '352cae89-7e94-45be-a405-c39099ebe515', # 'type': 'user', # 'identities': [ # {'id': 'bob', # 'provider': 'toy', # 'latest_login': '2022-10-02T02:47:57'}], # 'api_keys': [], # 'sessions': [{'uuid': 'e544d4b6-4750-43c3-8ba0-b7e9aedd2045', # 'expiration_time': '2023-10-01T19:28:15', # 'revoked': True}, # {'uuid': '66ee49c1-32b4-4778-8502-205e35151736', # 'expiration_time': '2023-10-01T19:30:03', # 'revoked': False}, # ..................................................... # {'uuid': 'c41d2f01-607e-49c0-9b3e-a93c383330c0', # 'expiration_time': '2023-10-02T02:47:57', # 'revoked': False}], # 'latest_activity': '2022-10-02T02:47:57', # 'roles': [], # 'scopes': [], # 'api_key_scopes': None}