Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions privx_api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,22 @@ def unpair_user_mobile_device(
path_params={"user_id": user_id, "device_id": device_id},
)
return self._api_response(response_status, HTTPStatus.OK, data)

def exchange_external_jwt_token(self, exchange_payload: dict) -> PrivXAPIResponse:
"""
Exchange external jwt token for privx token
Args:
exchange_payload:
{
"token": "string",
"scope": "privx-user connections-manual",
"client_id": "privx-ui"
}
Returns:
PrivXAPIResponse
"""
response_status, data = self._http_post(
UrlEnum.AUTH.EXCHANGE_JWT_TOKEN,
body=get_value(exchange_payload, dict()),
)
return self._api_response(response_status, HTTPStatus.OK, data)
8 changes: 7 additions & 1 deletion privx_api/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,22 @@ def search_connections(
)
return self._api_response(response_status, HTTPStatus.OK, data)

def get_connection(self, connection_id: str) -> PrivXAPIResponse:
def get_connection(
self,
connection_id: str,
verbose: Optional[bool] = False,
) -> PrivXAPIResponse:
"""
Get a single connection.

Returns:
PrivXAPIResponse
"""
search_params = self._get_search_params(verbose=bool(verbose))
response_status, data = self._http_get(
UrlEnum.CONNECTION_MANAGER.CONNECTION,
path_params={"connection_id": connection_id},
query_params=search_params,
)
return self._api_response(response_status, HTTPStatus.OK, data)

Expand Down
2 changes: 2 additions & 0 deletions privx_api/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AuthEnum:
LOGOUT = "AUTH.LOGOUT"
MGW_USER_DEVICES = "AUTH.MOBILE_GW_USER_DEVICES"
MGW_USER_DEVICES_UNPAIR = "AUTH.MOBILE_GW_USER_DEVICES_UNPAIR"
EXCHANGE_JWT_TOKEN = "AUTH.EXCHANGE_JWT_TOKEN"

urls = {
AUTHORIZE: "/auth/api/v1/oauth/authorize",
Expand All @@ -38,6 +39,7 @@ class AuthEnum:
LOGOUT: "/auth/api/v1/logout",
MGW_USER_DEVICES: "/auth/api/v1/users/{user_id}/devices",
MGW_USER_DEVICES_UNPAIR: "/auth/api/v1/users/{user_id}/devices/{device_id}",
EXCHANGE_JWT_TOKEN: "/auth/api/v1/token/login",
}


Expand Down
Loading