Repository: PrefectHQ/prefect

Issue:
Cloud PR references Core
See https://github.com/PrefectHQ/cloud/pull/1394 for more details


Discussion:

Resolving patch:
diff --git a/src/prefect/client/client.py b/src/prefect/client/client.py
--- a/src/prefect/client/client.py
+++ b/src/prefect/client/client.py
@@ -409,7 +409,7 @@ def login_to_tenant(self, tenant_slug: str = None, tenant_id: str = None) -> boo
                 "mutation($input: switchTenantInput!)": {
                     "switchTenant(input: $input)": {
                         "accessToken",
-                        "expiresIn",
+                        "expiresAt",
                         "refreshToken",
                     }
                 }
@@ -419,9 +419,9 @@ def login_to_tenant(self, tenant_slug: str = None, tenant_id: str = None) -> boo
             token=self._api_token,
         )  # type: ignore
         self._access_token = payload.data.switchTenant.accessToken  # type: ignore
-        self._access_token_expires_at = pendulum.now().add(
-            seconds=payload.data.switchTenant.expiresIn  # type: ignore
-        )
+        self._access_token_expires_at = pendulum.parse(
+            payload.data.switchTenant.expiresAt  # type: ignore
+        )  # type: ignore
         self._refresh_token = payload.data.switchTenant.refreshToken  # type: ignore
         self._active_tenant_id = tenant_id
 
@@ -456,7 +456,7 @@ def _refresh_access_token(self) -> bool:
                 "mutation($input: refreshTokenInput!)": {
                     "refreshToken(input: $input)": {
                         "accessToken",
-                        "expiresIn",
+                        "expiresAt",
                         "refreshToken",
                     }
                 }
@@ -466,9 +466,9 @@ def _refresh_access_token(self) -> bool:
             token=self._refresh_token,
         )  # type: ignore
         self._access_token = payload.data.refreshToken.accessToken  # type: ignore
-        self._access_token_expires_at = pendulum.now().add(
-            seconds=payload.data.refreshToken.expiresIn  # type: ignore
-        )
+        self._access_token_expires_at = pendulum.parse(
+            payload.data.refreshToken.expiresAt  # type: ignore
+        )  # type: ignore
         self._refresh_token = payload.data.refreshToken.refreshToken  # type: ignore
 
         return True


Test patch:
diff --git a/tests/client/test_client_auth.py b/tests/client/test_client_auth.py
--- a/tests/client/test_client_auth.py
+++ b/tests/client/test_client_auth.py
@@ -162,7 +162,7 @@ def test_login_to_client_sets_access_token(self, patch_post):
                     "tenant": [{"id": tenant_id}],
                     "switchTenant": {
                         "accessToken": "ACCESS_TOKEN",
-                        "expiresIn": 600,
+                        "expiresAt": "2100-01-01",
                         "refreshToken": "REFRESH_TOKEN",
                     },
                 }
@@ -183,7 +183,7 @@ def test_login_uses_api_token(self, patch_post):
                     "tenant": [{"id": tenant_id}],
                     "switchTenant": {
                         "accessToken": "ACCESS_TOKEN",
-                        "expiresIn": 600,
+                        "expiresAt": "2100-01-01",
                         "refreshToken": "REFRESH_TOKEN",
                     },
                 }
@@ -201,7 +201,7 @@ def test_login_uses_api_token_when_access_token_is_set(self, patch_post):
                     "tenant": [{"id": tenant_id}],
                     "switchTenant": {
                         "accessToken": "ACCESS_TOKEN",
-                        "expiresIn": 600,
+                        "expiresAt": "2100-01-01",
                         "refreshToken": "REFRESH_TOKEN",
                     },
                 }
@@ -221,7 +221,7 @@ def test_graphql_uses_access_token_after_login(self, patch_post):
                     "tenant": [{"id": tenant_id}],
                     "switchTenant": {
                         "accessToken": "ACCESS_TOKEN",
-                        "expiresIn": 600,
+                        "expiresAt": "2100-01-01",
                         "refreshToken": "REFRESH_TOKEN",
                     },
                 }
@@ -247,7 +247,7 @@ def test_login_to_tenant_writes_tenant_and_reloads_it_when_token_is_reloaded(
                     "tenant": [{"id": tenant_id}],
                     "switchTenant": {
                         "accessToken": "ACCESS_TOKEN",
-                        "expiresIn": 600,
+                        "expiresAt": "2100-01-01",
                         "refreshToken": "REFRESH_TOKEN",
                     },
                 }
@@ -274,7 +274,7 @@ def test_login_to_client_doesnt_reload_active_tenant_when_token_isnt_loaded(
                     "tenant": [{"id": tenant_id}],
                     "switchTenant": {
                         "accessToken": "ACCESS_TOKEN",
-                        "expiresIn": 600,
+                        "expiresAt": "2100-01-01",
                         "refreshToken": "REFRESH_TOKEN",
                     },
                 }
@@ -297,7 +297,7 @@ def test_logout_clears_access_token_and_tenant(self, patch_post):
                     "tenant": [{"id": tenant_id}],
                     "switchTenant": {
                         "accessToken": "ACCESS_TOKEN",
-                        "expiresIn": 600,
+                        "expiresAt": "2100-01-01",
                         "refreshToken": "REFRESH_TOKEN",
                     },
                 }
@@ -325,7 +325,7 @@ def test_refresh_token_sets_attributes(self, patch_post):
                 "data": {
                     "refreshToken": {
                         "accessToken": "ACCESS_TOKEN",
-                        "expiresIn": 600,
+                        "expiresAt": "2100-01-01",
                         "refreshToken": "REFRESH_TOKEN",
                     }
                 }
@@ -348,7 +348,7 @@ def test_refresh_token_passes_access_token_as_arg(self, patch_post):
                 "data": {
                     "refreshToken": {
                         "accessToken": "ACCESS_TOKEN",
-                        "expiresIn": 600,
+                        "expiresAt": "2100-01-01",
                         "refreshToken": "REFRESH_TOKEN",
                     }
                 }
@@ -366,7 +366,7 @@ def test_refresh_token_passes_refresh_token_as_header(self, patch_post):
                 "data": {
                     "refreshToken": {
                         "accessToken": "ACCESS_TOKEN",
-                        "expiresIn": 600,
+                        "expiresAt": "2100-01-01",
                         "refreshToken": "REFRESH_TOKEN",
                     }
                 }