From c5917f4d32290c3d26697f2025e3670aed4ef14a Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Fri, 26 Jan 2024 14:38:16 -0500 Subject: [PATCH] pass str(org_id) to cloud auth api --- engine/common/cloud_auth_api/client.py | 9 +++++---- engine/common/cloud_auth_api/tests/test_client.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/engine/common/cloud_auth_api/client.py b/engine/common/cloud_auth_api/client.py index 8cfc35982e..0694944aa0 100644 --- a/engine/common/cloud_auth_api/client.py +++ b/engine/common/cloud_auth_api/client.py @@ -45,20 +45,21 @@ def __init__(self): def request_signed_token( self, org: "Organization", scopes: typing.List[Scopes], claims: typing.Dict[str, typing.Any] ) -> str: - org_id = org.org_id - stack_id = org.stack_id + # The Cloud Auth API expects the org_id and stack_id to be strings + org_id = str(org.org_id) + stack_id = str(org.stack_id) # NOTE: header values must always be strings headers = { "Authorization": f"Bearer {self.api_token}", # need to cast to str otherwise - requests.exceptions.InvalidHeader: Header part ... from ('X-Org-ID', 5000) # must be of type str or bytes, not - "X-Org-ID": str(org_id), + "X-Org-ID": org_id, "X-Realms": json.dumps( [ { "type": "stack", - "identifier": str(stack_id), + "identifier": stack_id, }, ] ), diff --git a/engine/common/cloud_auth_api/tests/test_client.py b/engine/common/cloud_auth_api/tests/test_client.py index 2a10626ca4..4ef028f4d4 100644 --- a/engine/common/cloud_auth_api/tests/test_client.py +++ b/engine/common/cloud_auth_api/tests/test_client.py @@ -80,7 +80,7 @@ def _make_request(): "claims": claims, "extra": { "scopes": scopes, - "org_id": org_id, + "org_id": str(org_id), }, }, )