supabase_auth 0.1.0__tar.gz → 2.4.2__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 (27) hide show
  1. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/PKG-INFO +15 -14
  2. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/README.md +8 -8
  3. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/pyproject.toml +12 -12
  4. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/__init__.py +1 -1
  5. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_async/gotrue_client.py +93 -3
  6. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_sync/gotrue_client.py +93 -3
  7. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/helpers.py +10 -0
  8. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/types.py +25 -0
  9. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/LICENSE +0 -0
  10. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_async/__init__.py +0 -0
  11. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_async/gotrue_admin_api.py +0 -0
  12. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_async/gotrue_admin_mfa_api.py +0 -0
  13. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_async/gotrue_base_api.py +0 -0
  14. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_async/gotrue_mfa_api.py +0 -0
  15. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_async/storage.py +0 -0
  16. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_sync/__init__.py +0 -0
  17. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_sync/api.py +0 -0
  18. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_sync/client.py +0 -0
  19. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_sync/gotrue_admin_api.py +0 -0
  20. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_sync/gotrue_admin_mfa_api.py +0 -0
  21. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_sync/gotrue_base_api.py +0 -0
  22. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_sync/gotrue_mfa_api.py +0 -0
  23. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/_sync/storage.py +0 -0
  24. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/constants.py +0 -0
  25. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/errors.py +0 -0
  26. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/http_clients.py +0 -0
  27. {supabase_auth-0.1.0 → supabase_auth-2.4.2}/supabase_auth/timer.py +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: supabase_auth
3
- Version: 0.1.0
4
- Summary: Python Client Library for GoTrue
5
- Home-page: https://github.com/supabase-community/gotrue-py
3
+ Version: 2.4.2
4
+ Summary: Python Client Library for Supabase Auth
5
+ Home-page: https://github.com/supabase-community/auth-py
6
6
  License: MIT
7
7
  Author: Joel Lee
8
8
  Author-email: joel@joellee.org
@@ -14,13 +14,14 @@ Classifier: Programming Language :: Python :: 3.8
14
14
  Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
- Requires-Dist: httpx (>=0.23,<0.26)
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Dist: httpx (>=0.23,<0.28)
18
19
  Requires-Dist: pydantic (>=1.10,<3)
19
- Project-URL: Documentation, https://github.com/supabase-community/gotrue-py
20
- Project-URL: Repository, https://github.com/supabase-community/gotrue-py
20
+ Project-URL: Documentation, https://github.com/supabase-community/auth-py
21
+ Project-URL: Repository, https://github.com/supabase-community/auth-py
21
22
  Description-Content-Type: text/markdown
22
23
 
23
- # gotrue-py
24
+ # Auth-py
24
25
 
25
26
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?label=license)](https://opensource.org/licenses/MIT)
26
27
  [![CI](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml/badge.svg)](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml)
@@ -34,22 +35,22 @@ Description-Content-Type: text/markdown
34
35
  [![Github Watchers](https://img.shields.io/github/watchers/supabase-community/gotrue-py?style=flat&logo=github)](https://github.com/supabase-community/gotrue-py)
35
36
  [![GitHub contributors](https://img.shields.io/github/contributors/supabase-community/gotrue-py)](https://github.com/supabase-community/gotrue-py/graphs/contributors)
36
37
 
37
- This is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js). The current state is that there is a features parity but with small differences that are mentioned in the section **Differences to the JS client**.
38
+ This is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js). The current state is that there is a features parity but with small differences that are mentioned in the section **Differences to the JS client**. As of December 14th, we renamed to repo from `gotrue-py` to `auth-py` to mirror the changes in the JavaScript library.
38
39
 
39
40
  ## Installation
40
41
 
41
- We are still working on making the `gotrue` python library more user-friendly. For now here are some sparse notes on how to install the module.
42
+ We are still working on making the `supabase_auth` python library more user-friendly. For now here are some sparse notes on how to install the module.
42
43
 
43
44
  ### Poetry
44
45
 
45
46
  ```bash
46
- poetry add gotrue
47
+ poetry add supabase_auth
47
48
  ```
48
49
 
49
50
  ### Pip
50
51
 
51
52
  ```bash
52
- pip install gotrue
53
+ pip install supabase_auth
53
54
  ```
54
55
 
55
56
  ## Differences to the JS client
@@ -68,7 +69,7 @@ const { data, error } = client.sign_up(...)
68
69
 
69
70
  The other key difference is we do not use pascalCase to encode variable and method names. Instead we use the snake_case convention adopted in the Python language.
70
71
 
71
- Also, the `gotrue` library for Python parses the date-time string into `datetime` Python objects. The [JS client](https://github.com/supabase/gotrue-js) keeps the date-time as strings.
72
+ Also, the `supabase_auth` library for Python parses the date-time string into `datetime` Python objects. The [JS client](https://github.com/supabase/gotrue-js) keeps the date-time as strings.
72
73
 
73
74
  ## Usage (outdated)
74
75
 
@@ -77,7 +78,7 @@ Also, the `gotrue` library for Python parses the date-time string into `datetime
77
78
  To instantiate the client, you'll need the URL and any request headers at a minimum.
78
79
 
79
80
  ```python
80
- from gotrue import SyncGoTrueClient
81
+ from supabase_auth import SyncGoTrueClient
81
82
 
82
83
  headers = {
83
84
  "apiKey": "my-mega-awesome-api-key",
@@ -117,5 +118,5 @@ assert client.session() is not None
117
118
 
118
119
  ## Contributions
119
120
 
120
- We would be immensely grateful for any contributions to this project. In particular are the following items:
121
+ We would be immensely grateful for any contributions to this project.
121
122
 
@@ -1,4 +1,4 @@
1
- # gotrue-py
1
+ # Auth-py
2
2
 
3
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?label=license)](https://opensource.org/licenses/MIT)
4
4
  [![CI](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml/badge.svg)](https://github.com/supabase-community/gotrue-py/actions/workflows/ci.yml)
@@ -12,22 +12,22 @@
12
12
  [![Github Watchers](https://img.shields.io/github/watchers/supabase-community/gotrue-py?style=flat&logo=github)](https://github.com/supabase-community/gotrue-py)
13
13
  [![GitHub contributors](https://img.shields.io/github/contributors/supabase-community/gotrue-py)](https://github.com/supabase-community/gotrue-py/graphs/contributors)
14
14
 
15
- This is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js). The current state is that there is a features parity but with small differences that are mentioned in the section **Differences to the JS client**.
15
+ This is a Python port of the [supabase js gotrue client](https://github.com/supabase/gotrue-js). The current state is that there is a features parity but with small differences that are mentioned in the section **Differences to the JS client**. As of December 14th, we renamed to repo from `gotrue-py` to `auth-py` to mirror the changes in the JavaScript library.
16
16
 
17
17
  ## Installation
18
18
 
19
- We are still working on making the `gotrue` python library more user-friendly. For now here are some sparse notes on how to install the module.
19
+ We are still working on making the `supabase_auth` python library more user-friendly. For now here are some sparse notes on how to install the module.
20
20
 
21
21
  ### Poetry
22
22
 
23
23
  ```bash
24
- poetry add gotrue
24
+ poetry add supabase_auth
25
25
  ```
26
26
 
27
27
  ### Pip
28
28
 
29
29
  ```bash
30
- pip install gotrue
30
+ pip install supabase_auth
31
31
  ```
32
32
 
33
33
  ## Differences to the JS client
@@ -46,7 +46,7 @@ const { data, error } = client.sign_up(...)
46
46
 
47
47
  The other key difference is we do not use pascalCase to encode variable and method names. Instead we use the snake_case convention adopted in the Python language.
48
48
 
49
- Also, the `gotrue` library for Python parses the date-time string into `datetime` Python objects. The [JS client](https://github.com/supabase/gotrue-js) keeps the date-time as strings.
49
+ Also, the `supabase_auth` library for Python parses the date-time string into `datetime` Python objects. The [JS client](https://github.com/supabase/gotrue-js) keeps the date-time as strings.
50
50
 
51
51
  ## Usage (outdated)
52
52
 
@@ -55,7 +55,7 @@ Also, the `gotrue` library for Python parses the date-time string into `datetime
55
55
  To instantiate the client, you'll need the URL and any request headers at a minimum.
56
56
 
57
57
  ```python
58
- from gotrue import SyncGoTrueClient
58
+ from supabase_auth import SyncGoTrueClient
59
59
 
60
60
  headers = {
61
61
  "apiKey": "my-mega-awesome-api-key",
@@ -95,4 +95,4 @@ assert client.session() is not None
95
95
 
96
96
  ## Contributions
97
97
 
98
- We would be immensely grateful for any contributions to this project. In particular are the following items:
98
+ We would be immensely grateful for any contributions to this project.
@@ -1,11 +1,11 @@
1
1
  [tool.poetry]
2
2
  name = "supabase_auth"
3
- version = "0.1.0"
4
- description = "Python Client Library for GoTrue"
3
+ version = "2.4.2"
4
+ description = "Python Client Library for Supabase Auth"
5
5
  authors = ["Joel Lee <joel@joellee.org>"]
6
- homepage = "https://github.com/supabase-community/gotrue-py"
7
- repository = "https://github.com/supabase-community/gotrue-py"
8
- documentation = "https://github.com/supabase-community/gotrue-py"
6
+ homepage = "https://github.com/supabase-community/auth-py"
7
+ repository = "https://github.com/supabase-community/auth-py"
8
+ documentation = "https://github.com/supabase-community/auth-py"
9
9
  readme = "README.md"
10
10
  license = "MIT"
11
11
  classifiers = [
@@ -16,27 +16,27 @@ classifiers = [
16
16
 
17
17
  [tool.poetry.dependencies]
18
18
  python = "^3.8"
19
- httpx = ">=0.23,<0.26"
19
+ httpx = ">=0.23,<0.28"
20
20
  pydantic = ">=1.10,<3"
21
21
 
22
22
  [tool.poetry.dev-dependencies]
23
- pytest = "^7.4.2"
23
+ pytest = "^8.1.0"
24
24
  flake8 = "^5.0.4"
25
- black = "^23.9.1"
25
+ black = "^24.3.0"
26
26
  isort = "^5.12.0"
27
27
  pre-commit = "^3.4.0"
28
28
  pytest-cov = "^4.0.0"
29
29
  pytest-depends = "^1.0.1"
30
- pytest-asyncio = "^0.21.1"
31
- Faker = "^19.6.1"
30
+ pytest-asyncio = "^0.23.5"
31
+ Faker = "^23.3.0"
32
32
  unasync-cli = "^0.0.9"
33
- python-semantic-release = "^8.1.1"
33
+ python-semantic-release = "^9.1.1"
34
34
 
35
35
  [tool.poetry.group.dev.dependencies]
36
36
  pygithub = ">=1.57,<3.0"
37
37
 
38
38
  [tool.semantic_release]
39
- version_variables = ["gotrue/__init__.py:__version__"]
39
+ version_variables = ["supabase_auth/__init__.py:__version__"]
40
40
  version_toml = ["pyproject.toml:tool.poetry.version"]
41
41
  major_on_zero = false
42
42
  commit_message = "chore(release): bump version to v{version}"
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "2.1.0"
3
+ __version__ = "2.4.2"
4
4
 
5
5
  from ._async.gotrue_admin_api import AsyncGoTrueAdminAPI # type: ignore # noqa: F401
6
6
  from ._async.gotrue_client import AsyncGoTrueClient # type: ignore # noqa: F401
@@ -30,7 +30,9 @@ from ..helpers import (
30
30
  model_dump,
31
31
  model_dump_json,
32
32
  model_validate,
33
+ parse_auth_otp_response,
33
34
  parse_auth_response,
35
+ parse_sso_response,
34
36
  parse_user_response,
35
37
  )
36
38
  from ..http_clients import AsyncClient
@@ -45,9 +47,11 @@ from ..types import (
45
47
  AuthMFAListFactorsResponse,
46
48
  AuthMFAUnenrollResponse,
47
49
  AuthMFAVerifyResponse,
50
+ AuthOtpResponse,
48
51
  AuthResponse,
49
52
  CodeExchangeParams,
50
53
  DecodedJWTDict,
54
+ IdentitiesResponse,
51
55
  MFAChallengeAndVerifyParams,
52
56
  MFAChallengeParams,
53
57
  MFAEnrollParams,
@@ -253,6 +257,63 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
253
257
  self._notify_all_subscribers("SIGNED_IN", response.session)
254
258
  return response
255
259
 
260
+ async def sign_in_with_sso(self, credentials: SignInWithSSOCredentials):
261
+ """
262
+ Attempts a single-sign on using an enterprise Identity Provider. A
263
+ successful SSO attempt will redirect the current page to the identity
264
+ provider authorization page. The redirect URL is implementation and SSO
265
+ protocol specific.
266
+
267
+ You can use it by providing a SSO domain. Typically you can extract this
268
+ domain by asking users for their email address. If this domain is
269
+ registered on the Auth instance the redirect will use that organization's
270
+ currently active SSO Identity Provider for the login.
271
+ If you have built an organization-specific login page, you can use the
272
+ organization's SSO Identity Provider UUID directly instead.
273
+ """
274
+ self._remove_session()
275
+ provider_id = credentials.get("provider_id")
276
+ domain = credentials.get("domain")
277
+ options = credentials.get("options", {})
278
+ redirect_to = options.get("redirect_to")
279
+ captcha_token = options.get("captcha_token")
280
+ # HTTPX currently does not follow redirects: https://www.python-httpx.org/compatibility/
281
+ # Additionally, unlike the JS client, Python is a server side language and it's not possible
282
+ # to automatically redirect in browser for hte user
283
+ skip_http_redirect = options.get("skip_http_redirect", True)
284
+
285
+ if domain:
286
+ return self._request(
287
+ "POST",
288
+ "sso",
289
+ body={
290
+ "domain": domain,
291
+ "skip_http_redirect": skip_http_redirect,
292
+ "gotrue_meta_security": {
293
+ "captcha_token": captcha_token,
294
+ },
295
+ },
296
+ redirect_to=redirect_to,
297
+ xform=parse_sso_response,
298
+ )
299
+ if provider_id:
300
+ return self._request(
301
+ "POST",
302
+ "sso",
303
+ body={
304
+ "provider_id": provider_id,
305
+ "skip_http_redirect": skip_http_redirect,
306
+ "gotrue_meta_security": {
307
+ "captcha_token": captcha_token,
308
+ },
309
+ },
310
+ redirect_to=redirect_to,
311
+ xform=parse_sso_response,
312
+ )
313
+ raise AuthInvalidCredentialsError(
314
+ "You must provide either a domain or provider_id"
315
+ )
316
+
256
317
  async def sign_in_with_oauth(
257
318
  self,
258
319
  credentials: SignInWithOAuthCredentials,
@@ -274,10 +335,39 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
274
335
  url = await self._get_url_for_provider(provider, params)
275
336
  return OAuthResponse(provider=provider, url=url)
276
337
 
338
+ async def link_identity(self, credentials):
339
+ provider = credentials.get("provider")
340
+ options = credentials.get("options", {})
341
+ redirect_to = options.get("redirect_to")
342
+ scopes = options.get("scopes")
343
+ params = options.get("query_params", {})
344
+ if redirect_to:
345
+ params["redirect_to"] = redirect_to
346
+ if scopes:
347
+ params["scopes"] = scopes
348
+ params["skip_browser_redirect"] = True
349
+
350
+ url = await self._get_url_for_provider(provider, params)
351
+ return OAuthResponse(provider=provider, url=url)
352
+
353
+ async def get_user_identities(self):
354
+ response = self.get_user()
355
+ return (
356
+ IdentitiesResponse(identities=response.user.identities)
357
+ if response.user
358
+ else AuthSessionMissingError()
359
+ )
360
+
361
+ async def unlink_identity(self, identity):
362
+ return await self._request(
363
+ "POST",
364
+ f"/user/identities/{identity.id}",
365
+ )
366
+
277
367
  async def sign_in_with_otp(
278
368
  self,
279
369
  credentials: SignInWithPasswordlessCredentials,
280
- ) -> AuthResponse:
370
+ ) -> AuthOtpResponse:
281
371
  """
282
372
  Log in a user using magiclink or a one-time password (OTP).
283
373
 
@@ -311,7 +401,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
311
401
  },
312
402
  },
313
403
  redirect_to=email_redirect_to,
314
- xform=parse_auth_response,
404
+ xform=parse_auth_otp_response,
315
405
  )
316
406
  if phone:
317
407
  return await self._request(
@@ -325,7 +415,7 @@ class AsyncGoTrueClient(AsyncGoTrueBaseAPI):
325
415
  "captcha_token": captcha_token,
326
416
  },
327
417
  },
328
- xform=parse_auth_response,
418
+ xform=parse_auth_otp_response,
329
419
  )
330
420
  raise AuthInvalidCredentialsError(
331
421
  "You must provide either an email or phone number"
@@ -30,7 +30,9 @@ from ..helpers import (
30
30
  model_dump,
31
31
  model_dump_json,
32
32
  model_validate,
33
+ parse_auth_otp_response,
33
34
  parse_auth_response,
35
+ parse_sso_response,
34
36
  parse_user_response,
35
37
  )
36
38
  from ..http_clients import SyncClient
@@ -45,9 +47,11 @@ from ..types import (
45
47
  AuthMFAListFactorsResponse,
46
48
  AuthMFAUnenrollResponse,
47
49
  AuthMFAVerifyResponse,
50
+ AuthOtpResponse,
48
51
  AuthResponse,
49
52
  CodeExchangeParams,
50
53
  DecodedJWTDict,
54
+ IdentitiesResponse,
51
55
  MFAChallengeAndVerifyParams,
52
56
  MFAChallengeParams,
53
57
  MFAEnrollParams,
@@ -253,6 +257,63 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
253
257
  self._notify_all_subscribers("SIGNED_IN", response.session)
254
258
  return response
255
259
 
260
+ def sign_in_with_sso(self, credentials: SignInWithSSOCredentials):
261
+ """
262
+ Attempts a single-sign on using an enterprise Identity Provider. A
263
+ successful SSO attempt will redirect the current page to the identity
264
+ provider authorization page. The redirect URL is implementation and SSO
265
+ protocol specific.
266
+
267
+ You can use it by providing a SSO domain. Typically you can extract this
268
+ domain by asking users for their email address. If this domain is
269
+ registered on the Auth instance the redirect will use that organization's
270
+ currently active SSO Identity Provider for the login.
271
+ If you have built an organization-specific login page, you can use the
272
+ organization's SSO Identity Provider UUID directly instead.
273
+ """
274
+ self._remove_session()
275
+ provider_id = credentials.get("provider_id")
276
+ domain = credentials.get("domain")
277
+ options = credentials.get("options", {})
278
+ redirect_to = options.get("redirect_to")
279
+ captcha_token = options.get("captcha_token")
280
+ # HTTPX currently does not follow redirects: https://www.python-httpx.org/compatibility/
281
+ # Additionally, unlike the JS client, Python is a server side language and it's not possible
282
+ # to automatically redirect in browser for hte user
283
+ skip_http_redirect = options.get("skip_http_redirect", True)
284
+
285
+ if domain:
286
+ return self._request(
287
+ "POST",
288
+ "sso",
289
+ body={
290
+ "domain": domain,
291
+ "skip_http_redirect": skip_http_redirect,
292
+ "gotrue_meta_security": {
293
+ "captcha_token": captcha_token,
294
+ },
295
+ },
296
+ redirect_to=redirect_to,
297
+ xform=parse_sso_response,
298
+ )
299
+ if provider_id:
300
+ return self._request(
301
+ "POST",
302
+ "sso",
303
+ body={
304
+ "provider_id": provider_id,
305
+ "skip_http_redirect": skip_http_redirect,
306
+ "gotrue_meta_security": {
307
+ "captcha_token": captcha_token,
308
+ },
309
+ },
310
+ redirect_to=redirect_to,
311
+ xform=parse_sso_response,
312
+ )
313
+ raise AuthInvalidCredentialsError(
314
+ "You must provide either a domain or provider_id"
315
+ )
316
+
256
317
  def sign_in_with_oauth(
257
318
  self,
258
319
  credentials: SignInWithOAuthCredentials,
@@ -274,10 +335,39 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
274
335
  url = self._get_url_for_provider(provider, params)
275
336
  return OAuthResponse(provider=provider, url=url)
276
337
 
338
+ def link_identity(self, credentials):
339
+ provider = credentials.get("provider")
340
+ options = credentials.get("options", {})
341
+ redirect_to = options.get("redirect_to")
342
+ scopes = options.get("scopes")
343
+ params = options.get("query_params", {})
344
+ if redirect_to:
345
+ params["redirect_to"] = redirect_to
346
+ if scopes:
347
+ params["scopes"] = scopes
348
+ params["skip_browser_redirect"] = True
349
+
350
+ url = self._get_url_for_provider(provider, params)
351
+ return OAuthResponse(provider=provider, url=url)
352
+
353
+ def get_user_identities(self):
354
+ response = self.get_user()
355
+ return (
356
+ IdentitiesResponse(identities=response.user.identities)
357
+ if response.user
358
+ else AuthSessionMissingError()
359
+ )
360
+
361
+ def unlink_identity(self, identity):
362
+ return self._request(
363
+ "POST",
364
+ f"/user/identities/{identity.id}",
365
+ )
366
+
277
367
  def sign_in_with_otp(
278
368
  self,
279
369
  credentials: SignInWithPasswordlessCredentials,
280
- ) -> AuthResponse:
370
+ ) -> AuthOtpResponse:
281
371
  """
282
372
  Log in a user using magiclink or a one-time password (OTP).
283
373
 
@@ -311,7 +401,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
311
401
  },
312
402
  },
313
403
  redirect_to=email_redirect_to,
314
- xform=parse_auth_response,
404
+ xform=parse_auth_otp_response,
315
405
  )
316
406
  if phone:
317
407
  return self._request(
@@ -325,7 +415,7 @@ class SyncGoTrueClient(SyncGoTrueBaseAPI):
325
415
  "captcha_token": captcha_token,
326
416
  },
327
417
  },
328
- xform=parse_auth_response,
418
+ xform=parse_auth_otp_response,
329
419
  )
330
420
  raise AuthInvalidCredentialsError(
331
421
  "You must provide either an email or phone number"
@@ -13,10 +13,12 @@ from pydantic import BaseModel
13
13
 
14
14
  from .errors import AuthApiError, AuthError, AuthRetryableError, AuthUnknownError
15
15
  from .types import (
16
+ AuthOtpResponse,
16
17
  AuthResponse,
17
18
  GenerateLinkProperties,
18
19
  GenerateLinkResponse,
19
20
  Session,
21
+ SSOResponse,
20
22
  User,
21
23
  UserResponse,
22
24
  )
@@ -71,6 +73,10 @@ def parse_auth_response(data: Any) -> AuthResponse:
71
73
  return AuthResponse(session=session, user=user)
72
74
 
73
75
 
76
+ def parse_auth_otp_response(data: Any) -> AuthOtpResponse:
77
+ return model_validate(AuthOtpResponse, data)
78
+
79
+
74
80
  def parse_link_response(data: Any) -> GenerateLinkResponse:
75
81
  properties = GenerateLinkProperties(
76
82
  action_link=data.get("action_link"),
@@ -91,6 +97,10 @@ def parse_user_response(data: Any) -> UserResponse:
91
97
  return model_validate(UserResponse, data)
92
98
 
93
99
 
100
+ def parse_sso_response(data: Any) -> SSOResponse:
101
+ return model_validate(SSOResponse, data)
102
+
103
+
94
104
  def get_error_message(error: Any) -> str:
95
105
  props = ["msg", "message", "error_description", "error"]
96
106
  filter = (
@@ -89,11 +89,25 @@ class AuthResponse(BaseModel):
89
89
  session: Union[Session, None] = None
90
90
 
91
91
 
92
+ class AuthOtpResponse(BaseModel):
93
+ user: None = None
94
+ session: None = None
95
+ message_id: Union[str, None] = None
96
+
97
+
92
98
  class OAuthResponse(BaseModel):
93
99
  provider: Provider
94
100
  url: str
95
101
 
96
102
 
103
+ class SSOResponse(BaseModel):
104
+ url: str
105
+
106
+
107
+ class IdentitiesResponse(BaseModel):
108
+ identities: List[UserIdentity]
109
+
110
+
97
111
  class UserResponse(BaseModel):
98
112
  user: User
99
113
 
@@ -323,6 +337,17 @@ class SignInWithOAuthCredentials(TypedDict):
323
337
  options: NotRequired[SignInWithOAuthCredentialsOptions]
324
338
 
325
339
 
340
+ class SignInWithSSOCredentials(TypedDict):
341
+ provider_id: NotRequired[str]
342
+ domain: NotRequired[str]
343
+ options: NotRequired[SignInWithSSOOptions]
344
+
345
+
346
+ class SignInWithSSOOptions(TypedDict):
347
+ redirect_to: NotRequired[str]
348
+ skip_http_redirect: NotRequired[bool]
349
+
350
+
326
351
  class VerifyOtpParamsOptions(TypedDict):
327
352
  redirect_to: NotRequired[str]
328
353
  captcha_token: NotRequired[str]
File without changes