scalekit-sdk-python 1.1.0__tar.gz → 2.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/PKG-INFO +2 -2
  2. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/client.py +69 -6
  3. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/common/scalekit.py +15 -1
  4. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/core.py +1 -1
  5. scalekit_sdk_python-2.0.1/scalekit/users.py +367 -0
  6. scalekit_sdk_python-2.0.1/scalekit/v1/auth/auth_pb2.py +152 -0
  7. scalekit_sdk_python-2.0.1/scalekit/v1/auth/auth_pb2.pyi +212 -0
  8. scalekit_sdk_python-2.0.1/scalekit/v1/auth/auth_pb2_grpc.py +430 -0
  9. scalekit_sdk_python-2.0.1/scalekit/v1/auth/passwordless_pb2.py +98 -0
  10. scalekit_sdk_python-2.0.1/scalekit/v1/auth/passwordless_pb2.pyi +99 -0
  11. scalekit_sdk_python-2.0.1/scalekit/v1/auth/passwordless_pb2_grpc.py +132 -0
  12. scalekit_sdk_python-2.0.1/scalekit/v1/clients/clients_pb2.py +575 -0
  13. scalekit_sdk_python-2.0.1/scalekit/v1/clients/clients_pb2.pyi +639 -0
  14. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/clients/clients_pb2_grpc.py +330 -0
  15. scalekit_sdk_python-2.0.1/scalekit/v1/commons/commons_pb2.py +84 -0
  16. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/commons/commons_pb2.pyi +40 -26
  17. scalekit_sdk_python-2.0.1/scalekit/v1/connections/connections_pb2.py +511 -0
  18. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/connections/connections_pb2.pyi +55 -2
  19. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/connections/connections_pb2_grpc.py +66 -0
  20. scalekit_sdk_python-2.0.1/scalekit/v1/directories/directories_pb2.py +396 -0
  21. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/directories/directories_pb2.pyi +58 -8
  22. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/directories/directories_pb2_grpc.py +99 -0
  23. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/domains/domains_pb2.py +28 -18
  24. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/domains/domains_pb2.pyi +10 -0
  25. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/domains/domains_pb2_grpc.py +34 -0
  26. scalekit_sdk_python-2.0.1/scalekit/v1/emails/emails_pb2.py +287 -0
  27. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/emails/emails_pb2.pyi +94 -2
  28. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/emails/emails_pb2_grpc.py +66 -0
  29. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/environments/environments_pb2.py +108 -54
  30. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/environments/environments_pb2.pyi +79 -0
  31. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/environments/environments_pb2_grpc.py +132 -0
  32. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/events/events_pb2.py +2 -2
  33. scalekit_sdk_python-2.0.1/scalekit/v1/members/members_pb2.py +109 -0
  34. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/members/members_pb2.pyi +3 -2
  35. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/options/options_pb2.py +2 -2
  36. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/options/options_pb2.pyi +2 -0
  37. scalekit_sdk_python-2.0.1/scalekit/v1/organizations/organizations_pb2.py +309 -0
  38. scalekit_sdk_python-2.0.1/scalekit/v1/roles/roles_pb2.py +169 -0
  39. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/roles/roles_pb2.pyi +68 -4
  40. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/roles/roles_pb2_grpc.py +165 -0
  41. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/user_attributes/user_attributes_pb2.py +9 -9
  42. scalekit_sdk_python-2.0.1/scalekit/v1/users/users_pb2.py +322 -0
  43. scalekit_sdk_python-2.0.1/scalekit/v1/users/users_pb2.pyi +370 -0
  44. scalekit_sdk_python-2.0.1/scalekit/v1/users/users_pb2_grpc.py +401 -0
  45. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit_sdk_python.egg-info/PKG-INFO +2 -2
  46. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit_sdk_python.egg-info/SOURCES.txt +4 -4
  47. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit_sdk_python.egg-info/requires.txt +1 -1
  48. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/setup.py +2 -2
  49. scalekit_sdk_python-1.1.0/scalekit/v1/auth/auth_pb2.py +0 -77
  50. scalekit_sdk_python-1.1.0/scalekit/v1/auth/auth_pb2.pyi +0 -78
  51. scalekit_sdk_python-1.1.0/scalekit/v1/auth/auth_pb2_grpc.py +0 -199
  52. scalekit_sdk_python-1.1.0/scalekit/v1/clients/clients_pb2.py +0 -253
  53. scalekit_sdk_python-1.1.0/scalekit/v1/clients/clients_pb2.pyi +0 -304
  54. scalekit_sdk_python-1.1.0/scalekit/v1/commons/commons_pb2.py +0 -72
  55. scalekit_sdk_python-1.1.0/scalekit/v1/connections/connections_pb2.py +0 -472
  56. scalekit_sdk_python-1.1.0/scalekit/v1/directories/directories_pb2.py +0 -348
  57. scalekit_sdk_python-1.1.0/scalekit/v1/emails/emails_pb2.py +0 -236
  58. scalekit_sdk_python-1.1.0/scalekit/v1/login_box/login_box_pb2.py +0 -79
  59. scalekit_sdk_python-1.1.0/scalekit/v1/login_box/login_box_pb2.pyi +0 -88
  60. scalekit_sdk_python-1.1.0/scalekit/v1/login_box/login_box_pb2_grpc.py +0 -165
  61. scalekit_sdk_python-1.1.0/scalekit/v1/members/members_pb2.py +0 -108
  62. scalekit_sdk_python-1.1.0/scalekit/v1/organizations/organizations_pb2.py +0 -283
  63. scalekit_sdk_python-1.1.0/scalekit/v1/roles/roles_pb2.py +0 -111
  64. scalekit_sdk_python-1.1.0/scalekit/v1/users/users_pb2.py +0 -162
  65. scalekit_sdk_python-1.1.0/scalekit/v1/users/users_pb2.pyi +0 -171
  66. scalekit_sdk_python-1.1.0/scalekit/v1/users/users_pb2_grpc.py +0 -232
  67. scalekit_sdk_python-1.1.0/scalekit/v1/workspaces/__init__.py +0 -0
  68. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/LICENSE +0 -0
  69. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/README.md +0 -0
  70. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/__init__.py +0 -0
  71. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/__init__.py +0 -0
  72. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/expression_pb2.py +0 -0
  73. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/expression_pb2.pyi +0 -0
  74. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/expression_pb2_grpc.py +0 -0
  75. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/priv/__init__.py +0 -0
  76. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/priv/private_pb2.py +0 -0
  77. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/priv/private_pb2.pyi +0 -0
  78. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/priv/private_pb2_grpc.py +0 -0
  79. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/validate_pb2.py +0 -0
  80. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/validate_pb2.pyi +0 -0
  81. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/buf/validate/validate_pb2_grpc.py +0 -0
  82. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/__init__.py +0 -0
  83. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/common/__init__.py +0 -0
  84. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/common/user.py +0 -0
  85. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/connection.py +0 -0
  86. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/constants/__init__.py +0 -0
  87. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/constants/user.py +0 -0
  88. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/directory.py +0 -0
  89. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/domain.py +0 -0
  90. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/m2m_client.py +0 -0
  91. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/organization.py +0 -0
  92. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/utils/__init__.py +0 -0
  93. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/utils/directory.py +0 -0
  94. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/__init__.py +0 -0
  95. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/auth/__init__.py +0 -0
  96. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/clients/__init__.py +0 -0
  97. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/commons/__init__.py +0 -0
  98. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/commons/commons_pb2_grpc.py +0 -0
  99. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/connections/__init__.py +0 -0
  100. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/directories/__init__.py +0 -0
  101. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/domains/__init__.py +0 -0
  102. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/emails/__init__.py +0 -0
  103. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/environments/__init__.py +0 -0
  104. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/errdetails/__init__.py +0 -0
  105. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/errdetails/errdetails_pb2.py +0 -0
  106. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/errdetails/errdetails_pb2.pyi +0 -0
  107. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/errdetails/errdetails_pb2_grpc.py +0 -0
  108. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/events/__init__.py +0 -0
  109. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/events/events_pb2.pyi +0 -0
  110. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/events/events_pb2_grpc.py +0 -0
  111. {scalekit_sdk_python-1.1.0/scalekit/v1/login_box → scalekit_sdk_python-2.0.1/scalekit/v1/members}/__init__.py +0 -0
  112. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/members/members_pb2_grpc.py +0 -0
  113. {scalekit_sdk_python-1.1.0/scalekit/v1/members → scalekit_sdk_python-2.0.1/scalekit/v1/migrations}/__init__.py +0 -0
  114. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/migrations/migrations_pb2.py +0 -0
  115. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/migrations/migrations_pb2.pyi +0 -0
  116. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/migrations/migrations_pb2_grpc.py +0 -0
  117. {scalekit_sdk_python-1.1.0/scalekit/v1/migrations → scalekit_sdk_python-2.0.1/scalekit/v1/options}/__init__.py +0 -0
  118. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/options/options_pb2_grpc.py +0 -0
  119. {scalekit_sdk_python-1.1.0/scalekit/v1/options → scalekit_sdk_python-2.0.1/scalekit/v1/organizations}/__init__.py +0 -0
  120. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/organizations/organizations_pb2.pyi +0 -0
  121. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/organizations/organizations_pb2_grpc.py +0 -0
  122. {scalekit_sdk_python-1.1.0/scalekit/v1/organizations → scalekit_sdk_python-2.0.1/scalekit/v1/roles}/__init__.py +0 -0
  123. {scalekit_sdk_python-1.1.0/scalekit/v1/roles → scalekit_sdk_python-2.0.1/scalekit/v1/user_attributes}/__init__.py +0 -0
  124. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/user_attributes/user_attributes_pb2.pyi +0 -0
  125. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/user_attributes/user_attributes_pb2_grpc.py +0 -0
  126. {scalekit_sdk_python-1.1.0/scalekit/v1/user_attributes → scalekit_sdk_python-2.0.1/scalekit/v1/users}/__init__.py +0 -0
  127. {scalekit_sdk_python-1.1.0/scalekit/v1/users → scalekit_sdk_python-2.0.1/scalekit/v1/webhooks}/__init__.py +0 -0
  128. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/webhooks/webhooks_pb2.py +0 -0
  129. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/webhooks/webhooks_pb2.pyi +0 -0
  130. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/webhooks/webhooks_pb2_grpc.py +0 -0
  131. {scalekit_sdk_python-1.1.0/scalekit/v1/webhooks → scalekit_sdk_python-2.0.1/scalekit/v1/workspaces}/__init__.py +0 -0
  132. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/workspaces/workspaces_pb2.py +0 -0
  133. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/workspaces/workspaces_pb2.pyi +0 -0
  134. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit/v1/workspaces/workspaces_pb2_grpc.py +0 -0
  135. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit_sdk_python.egg-info/dependency_links.txt +0 -0
  136. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/scalekit_sdk_python.egg-info/top_level.txt +0 -0
  137. {scalekit_sdk_python-1.1.0 → scalekit_sdk_python-2.0.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scalekit-sdk-python
3
- Version: 1.1.0
3
+ Version: 2.0.1
4
4
  Summary: Scalekit official Python SDK
5
5
  Home-page: https://github.com/scalekit-inc/scalekit-sdk-python
6
6
  Author: Team Scalekit
@@ -18,7 +18,7 @@ Requires-Dist: requests>=2.32.3
18
18
  Requires-Dist: PyJWT<2.10,>=2.8
19
19
  Requires-Dist: cffi>=1.15.1
20
20
  Requires-Dist: cryptography==44.0.1
21
- Requires-Dist: setuptools~=70.3
21
+ Requires-Dist: setuptools>=78.1.1
22
22
  Requires-Dist: grpcio-status<1.67,>=1.64
23
23
  Requires-Dist: protoc-gen-openapiv2>=0.0.1
24
24
  Requires-Dist: googleapis-common-protos<1.66.0,>=1.56.1
@@ -1,4 +1,3 @@
1
-
2
1
  import json
3
2
  from math import floor
4
3
  from typing import Any, Optional, Dict
@@ -15,15 +14,18 @@ from scalekit.connection import ConnectionClient
15
14
  from scalekit.m2m_client import M2MClient
16
15
  from scalekit.organization import OrganizationClient
17
16
  from scalekit.directory import DirectoryClient
17
+ from scalekit.users import UserClient
18
18
  from scalekit.common.scalekit import (
19
19
  AuthorizationUrlOptions,
20
20
  CodeAuthenticationOptions,
21
21
  GrantType,
22
22
  IdpInitiatedLoginClaims,
23
+ LogoutUrlOptions,
23
24
  )
24
25
  from scalekit.constants.user import id_token_claim_to_user_map
25
26
 
26
27
  AUTHORIZE_ENDPOINT = "oauth/authorize"
28
+ LOGOUT_ENDPOINT = "end_session"
27
29
  webhook_tolerance_in_seconds = timedelta(minutes=5)
28
30
  webhook_signature_version = "v1"
29
31
 
@@ -58,6 +60,7 @@ class ScalekitClient:
58
60
  self.organization = OrganizationClient(self.core_client)
59
61
  self.directory = DirectoryClient(self.core_client)
60
62
  self.m2m_client = M2MClient(self.core_client)
63
+ self.users = UserClient(self.core_client)
61
64
  except Exception as exp:
62
65
  raise exp
63
66
 
@@ -91,6 +94,7 @@ class ScalekitClient:
91
94
  "connection_id": options.connection_id,
92
95
  "organization_id": options.organization_id,
93
96
  "provider": options.provider,
97
+ "prompt": options.prompt,
94
98
  }
95
99
 
96
100
  valid_auth_params = {k: v for k, v in url_params_dict.items() if v}
@@ -114,7 +118,7 @@ class ScalekitClient:
114
118
  :type : ``` obj ```
115
119
 
116
120
  :returns:
117
- dict with user, id token & access token
121
+ dict with user, id token, optionally access token & refresh token
118
122
  """
119
123
  try:
120
124
  response = self.core_client.authenticate(
@@ -132,11 +136,13 @@ class ScalekitClient:
132
136
  response = json.loads(response.content)
133
137
  id_token = response["id_token"]
134
138
  access_token = response["access_token"]
139
+ refresh_token = response.get("refresh_token")
135
140
  # Validate id_token
136
141
  claims = self.__validate_token(id_token, {"verify_aud": False})
137
142
  user = {}
138
- connection_id = claims['amr'][0]
139
- organization_id = claims['oid']
143
+ amr_claims = claims.get('amr', [])
144
+ connection_id = amr_claims[0] if amr_claims else None
145
+ organization_id = claims.get('oid')
140
146
  for k, v in claims.items():
141
147
  if id_token_claim_to_user_map.get(k, None):
142
148
  user[id_token_claim_to_user_map[k]] = v
@@ -145,6 +151,7 @@ class ScalekitClient:
145
151
  "user": user,
146
152
  "id_token": id_token,
147
153
  "access_token": access_token,
154
+ "refresh_token": refresh_token,
148
155
  "connection_id": connection_id,
149
156
  "organization_id": organization_id
150
157
  }
@@ -152,7 +159,7 @@ class ScalekitClient:
152
159
  except Exception as exp:
153
160
  raise exp
154
161
 
155
- def validate_access_token(self, token: str) -> bool:
162
+ def validate_access_token(self, token: str, options: Optional[Dict] = None, audience = None) -> bool:
156
163
  """
157
164
  Method to validate access token
158
165
 
@@ -162,8 +169,10 @@ class ScalekitClient:
162
169
  :returns:
163
170
  bool
164
171
  """
172
+ options = options if options else {}
173
+ options["verify_aud"] = False if not audience else True
165
174
  try:
166
- self.__validate_token(token)
175
+ self.__validate_token(token, options=options, audience=audience)
167
176
  return True
168
177
  except jwt.exceptions.InvalidTokenError:
169
178
  return False
@@ -345,3 +354,57 @@ class ScalekitClient:
345
354
  """
346
355
  signature = hmac.new(secret, data.encode(), hashlib.sha256).digest()
347
356
  return f"v1, {base64.b64encode(signature).decode('utf-8')}"
357
+
358
+ def refresh_access_token(self, refresh_token: str):
359
+ """
360
+ Method to refresh access token using refresh token
361
+
362
+ :param refresh_token : Refresh token to get new access token
363
+ :type : ``` str ```
364
+
365
+ :returns:
366
+ dict with access token & refresh token
367
+ """
368
+ try:
369
+ response = self.core_client.authenticate(
370
+ json.dumps(
371
+ {
372
+ "refresh_token": refresh_token,
373
+ "grant_type": GrantType.RefreshToken.value,
374
+ "client_id": self.core_client.client_id,
375
+ "client_secret": self.core_client.client_secret,
376
+ }
377
+ )
378
+ )
379
+ response = json.loads(response.content)
380
+ return {
381
+ "access_token": response["access_token"],
382
+ "refresh_token": response["refresh_token"]
383
+ }
384
+
385
+ except Exception as exp:
386
+ raise exp
387
+
388
+ def get_logout_url(self, options: LogoutUrlOptions) -> str:
389
+ """
390
+ Method to get logout URL
391
+
392
+ :param options : Logout URL options object
393
+ :type : ``` LogoutUrlOptions ```
394
+
395
+ :returns:
396
+ str: The logout URL
397
+ """
398
+ try:
399
+ url_params_dict = {
400
+ "id_token_hint": options.id_token_hint,
401
+ "post_logout_redirect_uri": options.post_logout_redirect_uri,
402
+ "state": options.state
403
+ }
404
+
405
+ valid_params = {k: v for k, v in url_params_dict.items() if v is not None}
406
+ query_string = urlencode(valid_params)
407
+
408
+ return f"{self.core_client.env_url}/{LOGOUT_ENDPOINT}?{query_string}"
409
+ except Exception as exp:
410
+ raise exp
@@ -23,6 +23,7 @@ class AuthorizationUrlOptions:
23
23
  self.domain_hint: Optional[str] = None
24
24
  self.login_hint: Optional[str] = None
25
25
  self.provider: Optional[str] = None
26
+ self.prompt: Optional[str] = None
26
27
 
27
28
 
28
29
  class CodeAuthenticationOptions:
@@ -57,4 +58,17 @@ class IdpInitiatedLoginClaims:
57
58
  self.connection_id: str
58
59
  self.organization_id: str
59
60
  self.login_hint: str
60
- self.relay_state: Optional[str] = None
61
+ self.relay_state: Optional[str] = None
62
+
63
+
64
+ class LogoutUrlOptions:
65
+ """Options for logout URL generation"""
66
+ def __init__(
67
+ self,
68
+ id_token_hint: Optional[str] = None,
69
+ post_logout_redirect_uri: Optional[str] = None,
70
+ state: Optional[str] = None
71
+ ):
72
+ self.id_token_hint = id_token_hint
73
+ self.post_logout_redirect_uri = post_logout_redirect_uri
74
+ self.state = state
@@ -27,7 +27,7 @@ class WithCall(Protocol):
27
27
  class CoreClient:
28
28
  """Class definition for Core Client"""
29
29
 
30
- sdk_version = "Scalekit-Python/1.1.0"
30
+ sdk_version = "Scalekit-Python/2.0.1"
31
31
  api_version = "20250417"
32
32
  user_agent = f"{sdk_version} Python/{platform.python_version()} ({platform.system()}; {platform.architecture()}"
33
33
 
@@ -0,0 +1,367 @@
1
+ from typing import Optional
2
+
3
+ from scalekit.core import CoreClient
4
+ from scalekit.v1.users.users_pb2 import *
5
+ from scalekit.v1.users.users_pb2_grpc import UserServiceStub
6
+
7
+
8
+ class UserClient:
9
+ """Class definition for User Client"""
10
+
11
+ def __init__(self, core_client: CoreClient):
12
+ """
13
+ Initializer for User Client
14
+
15
+ :param core_client : CoreClient Object
16
+ :type : ``` obj ```
17
+ :returns
18
+ None
19
+ """
20
+ self.core_client = core_client
21
+ self.user_service = UserServiceStub(
22
+ self.core_client.grpc_secure_channel
23
+ )
24
+
25
+ def create_user_and_membership(
26
+ self,
27
+ organization_id: str,
28
+ user: CreateUser,
29
+ send_invitation_email: bool = True
30
+ ) -> CreateUserAndMembershipResponse:
31
+ """
32
+ Method to create a new user and add them to an organization
33
+
34
+ :param organization_id : Organization id to create user for
35
+ :type : ``` str ```
36
+ :param user : CreateUser object with expected values for user creation
37
+ :type : ``` obj ```
38
+ :param send_invitation_email: Whether to send activation email to the user
39
+ :type : ``` bool ```
40
+
41
+ :returns:
42
+ Create User And Membership Response
43
+ """
44
+ return self.core_client.grpc_exec(
45
+ self.user_service.CreateUserAndMembership.with_call,
46
+ CreateUserAndMembershipRequest(
47
+ organization_id=organization_id,
48
+ user=user,
49
+ send_invitation_email=send_invitation_email
50
+ ),
51
+ )
52
+
53
+ def get_user(self, user_id: str) -> GetUserResponse:
54
+ """
55
+ Method to get user by ID
56
+
57
+ :param user_id : User id to get user details
58
+ :type : ``` str ```
59
+
60
+ :returns:
61
+ Get User Response
62
+ """
63
+ return self.core_client.grpc_exec(
64
+ self.user_service.GetUser.with_call,
65
+ GetUserRequest(id=user_id),
66
+ )
67
+
68
+ def get_user_by_external_id(self, external_id: str) -> GetUserResponse:
69
+ """
70
+ Method to get user by external ID
71
+
72
+ :param external_id : External id to get user details
73
+ :type : ``` str ```
74
+
75
+ :returns:
76
+ Get User Response
77
+ """
78
+ return self.core_client.grpc_exec(
79
+ self.user_service.GetUser.with_call,
80
+ GetUserRequest(external_id=external_id),
81
+ )
82
+
83
+ def list_users(
84
+ self,
85
+ page_size: Optional[int] = None,
86
+ page_token: Optional[str] = None
87
+ ) -> ListUsersResponse:
88
+ """
89
+ Method to list all users in environment
90
+
91
+ :param page_size : Page size for pagination
92
+ :type : ``` int ```
93
+ :param page_token : Page token for pagination
94
+ :type : ``` str ```
95
+
96
+ :returns:
97
+ List Users Response
98
+ """
99
+ return self.core_client.grpc_exec(
100
+ self.user_service.ListUsers.with_call,
101
+ ListUsersRequest(
102
+ page_size=page_size,
103
+ page_token=page_token
104
+ ),
105
+ )
106
+
107
+ def list_organization_users(
108
+ self,
109
+ organization_id: str,
110
+ page_size: Optional[int] = None,
111
+ page_token: Optional[str] = None
112
+ ) -> ListOrganizationUsersResponse:
113
+ """
114
+ Method to list users for given organization id
115
+
116
+ :param organization_id : Organization id to list users for
117
+ :type : ``` str ```
118
+ :param page_size : Page size for pagination
119
+ :type : ``` int ```
120
+ :param page_token : Page token for pagination
121
+ :type : ``` str ```
122
+
123
+ :returns:
124
+ List Organization Users Response
125
+ """
126
+ return self.core_client.grpc_exec(
127
+ self.user_service.ListOrganizationUsers.with_call,
128
+ ListOrganizationUsersRequest(
129
+ organization_id=organization_id,
130
+ page_size=page_size,
131
+ page_token=page_token
132
+ ),
133
+ )
134
+
135
+ def update_user(self, user_id: str, user: UpdateUser) -> UpdateUserResponse:
136
+ """
137
+ Method to update an existing user by ID
138
+
139
+ :param user_id : User id to update
140
+ :type : ``` str ```
141
+ :param user : UpdateUser object with expected values for user update
142
+ :type : ``` obj ```
143
+
144
+ :returns:
145
+ Update User Response
146
+ """
147
+ return self.core_client.grpc_exec(
148
+ self.user_service.UpdateUser.with_call,
149
+ UpdateUserRequest(id=user_id, user=user),
150
+ )
151
+
152
+ def update_user_by_external_id(self, external_id: str, user: UpdateUser) -> UpdateUserResponse:
153
+ """
154
+ Method to update an existing user by external ID
155
+
156
+ :param external_id : External id to update
157
+ :type : ``` str ```
158
+ :param user : UpdateUser object with expected values for user update
159
+ :type : ``` obj ```
160
+
161
+ :returns:
162
+ Update User Response
163
+ """
164
+ return self.core_client.grpc_exec(
165
+ self.user_service.UpdateUser.with_call,
166
+ UpdateUserRequest(external_id=external_id, user=user),
167
+ )
168
+
169
+ def delete_user(self, user_id: str):
170
+ """
171
+ Method to delete user by ID
172
+
173
+ :param user_id : User id to be deleted
174
+ :type : ``` str ```
175
+
176
+ :returns:
177
+ None
178
+ """
179
+ return self.core_client.grpc_exec(
180
+ self.user_service.DeleteUser.with_call,
181
+ DeleteUserRequest(id=user_id),
182
+ )
183
+
184
+ def delete_user_by_external_id(self, external_id: str):
185
+ """
186
+ Method to delete user by external ID
187
+
188
+ :param external_id : External id to be deleted
189
+ :type : ``` str ```
190
+
191
+ :returns:
192
+ None
193
+ """
194
+ return self.core_client.grpc_exec(
195
+ self.user_service.DeleteUser.with_call,
196
+ DeleteUserRequest(external_id=external_id),
197
+ )
198
+
199
+ def create_membership(
200
+ self,
201
+ organization_id: str,
202
+ user_id: str,
203
+ membership: CreateMembership,
204
+ send_invitation_email: bool = True
205
+ ) -> CreateMembershipResponse:
206
+ """
207
+ Method to create a membership for a user by user ID
208
+
209
+ :param organization_id : Organization id
210
+ :type : ``` str ```
211
+ :param user_id : User id
212
+ :type : ``` str ```
213
+ :param membership : CreateMembership object
214
+ :type : ``` obj ```
215
+ :param send_invitation_email: Whether to send activation email to the user
216
+ :type : ``` bool ```
217
+
218
+ :returns:
219
+ Create Membership Response
220
+ """
221
+ return self.core_client.grpc_exec(
222
+ self.user_service.CreateMembership.with_call,
223
+ CreateMembershipRequest(
224
+ organization_id=organization_id,
225
+ id=user_id,
226
+ membership=membership,
227
+ send_invitation_email=send_invitation_email
228
+ ),
229
+ )
230
+
231
+ def create_membership_by_external_id(
232
+ self,
233
+ organization_id: str,
234
+ external_id: str,
235
+ membership: CreateMembership,
236
+ send_invitation_email: bool = True
237
+ ) -> CreateMembershipResponse:
238
+ """
239
+ Method to create a membership for a user by external ID
240
+
241
+ :param organization_id : Organization id
242
+ :type : ``` str ```
243
+ :param external_id : External id
244
+ :type : ``` str ```
245
+ :param membership : CreateMembership object
246
+ :type : ``` obj ```
247
+ :param send_invitation_email: Whether to send activation email to the user
248
+ :type : ``` bool ```
249
+
250
+ :returns:
251
+ Create Membership Response
252
+ """
253
+ return self.core_client.grpc_exec(
254
+ self.user_service.CreateMembership.with_call,
255
+ CreateMembershipRequest(
256
+ organization_id=organization_id,
257
+ external_id=external_id,
258
+ membership=membership,
259
+ send_invitation_email=send_invitation_email
260
+ ),
261
+ )
262
+
263
+ def update_membership(
264
+ self,
265
+ organization_id: str,
266
+ user_id: str,
267
+ membership: UpdateMembership
268
+ ) -> UpdateMembershipResponse:
269
+ """
270
+ Method to update a membership for a user by user ID
271
+
272
+ :param organization_id : Organization id
273
+ :type : ``` str ```
274
+ :param user_id : User id
275
+ :type : ``` str ```
276
+ :param membership : UpdateMembership object
277
+ :type : ``` obj ```
278
+
279
+ :returns:
280
+ Update Membership Response
281
+ """
282
+ return self.core_client.grpc_exec(
283
+ self.user_service.UpdateMembership.with_call,
284
+ UpdateMembershipRequest(
285
+ organization_id=organization_id,
286
+ id=user_id,
287
+ membership=membership
288
+ ),
289
+ )
290
+
291
+ def update_membership_by_external_id(
292
+ self,
293
+ organization_id: str,
294
+ external_id: str,
295
+ membership: UpdateMembership
296
+ ) -> UpdateMembershipResponse:
297
+ """
298
+ Method to update a membership for a user by external ID
299
+
300
+ :param organization_id : Organization id
301
+ :type : ``` str ```
302
+ :param external_id : External id
303
+ :type : ``` str ```
304
+ :param membership : UpdateMembership object
305
+ :type : ``` obj ```
306
+
307
+ :returns:
308
+ Update Membership Response
309
+ """
310
+ return self.core_client.grpc_exec(
311
+ self.user_service.UpdateMembership.with_call,
312
+ UpdateMembershipRequest(
313
+ organization_id=organization_id,
314
+ external_id=external_id,
315
+ membership=membership
316
+ ),
317
+ )
318
+
319
+ def delete_membership(
320
+ self,
321
+ organization_id: str,
322
+ user_id: str
323
+ ):
324
+ """
325
+ Method to delete a membership for a user by user ID
326
+
327
+ :param organization_id : Organization id
328
+ :type : ``` str ```
329
+ :param user_id : User id
330
+ :type : ``` str ```
331
+
332
+ :returns:
333
+ None
334
+ """
335
+ return self.core_client.grpc_exec(
336
+ self.user_service.DeleteMembership.with_call,
337
+ DeleteMembershipRequest(
338
+ organization_id=organization_id,
339
+ id=user_id
340
+ ),
341
+ )
342
+
343
+ def delete_membership_by_external_id(
344
+ self,
345
+ organization_id: str,
346
+ external_id: str
347
+ ):
348
+ """
349
+ Method to delete a membership for a user by external ID
350
+
351
+ :param organization_id : Organization id
352
+ :type : ``` str ```
353
+ :param external_id : External id
354
+ :type : ``` str ```
355
+
356
+ :returns:
357
+ None
358
+ """
359
+ return self.core_client.grpc_exec(
360
+ self.user_service.DeleteMembership.with_call,
361
+ DeleteMembershipRequest(
362
+ organization_id=organization_id,
363
+ external_id=external_id
364
+ ),
365
+ )
366
+
367
+