|
11 | 11 | import jwt |
12 | 12 |
|
13 | 13 | from stytch.b2b.models.sessions import ( |
| 14 | + AttestResponse, |
14 | 15 | AuthenticateJWTLocalResponse, |
15 | 16 | AuthenticateResponse, |
16 | 17 | AuthorizationCheck, |
@@ -532,14 +533,75 @@ async def exchange_access_token_async( |
532 | 533 | res = await self.async_client.post(url, data, headers) |
533 | 534 | return ExchangeAccessTokenResponse.from_json(res.response.status, res.json) |
534 | 535 |
|
| 536 | + def attest( |
| 537 | + self, |
| 538 | + organization_id: str, |
| 539 | + profile_id: str, |
| 540 | + token: str, |
| 541 | + session_duration_minutes: Optional[int] = None, |
| 542 | + session_custom_claims: Optional[Dict[str, Any]] = None, |
| 543 | + session_token: Optional[str] = None, |
| 544 | + session_jwt: Optional[str] = None, |
| 545 | + ) -> AttestResponse: |
| 546 | + headers: Dict[str, str] = {} |
| 547 | + data: Dict[str, Any] = { |
| 548 | + "organization_id": organization_id, |
| 549 | + "profile_id": profile_id, |
| 550 | + "token": token, |
| 551 | + } |
| 552 | + if session_duration_minutes is not None: |
| 553 | + data["session_duration_minutes"] = session_duration_minutes |
| 554 | + if session_custom_claims is not None: |
| 555 | + data["session_custom_claims"] = session_custom_claims |
| 556 | + if session_token is not None: |
| 557 | + data["session_token"] = session_token |
| 558 | + if session_jwt is not None: |
| 559 | + data["session_jwt"] = session_jwt |
| 560 | + |
| 561 | + url = self.api_base.url_for("/v1/b2b/sessions/attest", data) |
| 562 | + res = self.sync_client.post(url, data, headers) |
| 563 | + return AttestResponse.from_json(res.response.status_code, res.json) |
| 564 | + |
| 565 | + async def attest_async( |
| 566 | + self, |
| 567 | + organization_id: str, |
| 568 | + profile_id: str, |
| 569 | + token: str, |
| 570 | + session_duration_minutes: Optional[int] = None, |
| 571 | + session_custom_claims: Optional[Dict[str, Any]] = None, |
| 572 | + session_token: Optional[str] = None, |
| 573 | + session_jwt: Optional[str] = None, |
| 574 | + ) -> AttestResponse: |
| 575 | + headers: Dict[str, str] = {} |
| 576 | + data: Dict[str, Any] = { |
| 577 | + "organization_id": organization_id, |
| 578 | + "profile_id": profile_id, |
| 579 | + "token": token, |
| 580 | + } |
| 581 | + if session_duration_minutes is not None: |
| 582 | + data["session_duration_minutes"] = session_duration_minutes |
| 583 | + if session_custom_claims is not None: |
| 584 | + data["session_custom_claims"] = session_custom_claims |
| 585 | + if session_token is not None: |
| 586 | + data["session_token"] = session_token |
| 587 | + if session_jwt is not None: |
| 588 | + data["session_jwt"] = session_jwt |
| 589 | + |
| 590 | + url = self.api_base.url_for("/v1/b2b/sessions/attest", data) |
| 591 | + res = await self.async_client.post(url, data, headers) |
| 592 | + return AttestResponse.from_json(res.response.status, res.json) |
| 593 | + |
535 | 594 | def migrate( |
536 | 595 | self, |
537 | 596 | session_token: str, |
538 | 597 | organization_id: str, |
539 | 598 | session_duration_minutes: Optional[int] = None, |
540 | 599 | session_custom_claims: Optional[Dict[str, Any]] = None, |
541 | 600 | ) -> MigrateResponse: |
542 | | - """Migrate a session from an external OIDC compliant endpoint. Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. If the response contains a valid email address, Stytch will attempt to match that email address with an existing in your and create a Stytch Session. You will need to create the member before using this endpoint. |
| 601 | + """Migrate a session from an external OIDC compliant endpoint. |
| 602 | + Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. <!-- FIXME more specific dashboard link--> |
| 603 | + If the response contains a valid email address, Stytch will attempt to match that email address with an existing in your and create a Stytch Session. |
| 604 | + You will need to create the member before using this endpoint. |
543 | 605 |
|
544 | 606 | Fields: |
545 | 607 | - session_token: The authorization token Stytch will pass in to the external userinfo endpoint. |
@@ -580,7 +642,10 @@ async def migrate_async( |
580 | 642 | session_duration_minutes: Optional[int] = None, |
581 | 643 | session_custom_claims: Optional[Dict[str, Any]] = None, |
582 | 644 | ) -> MigrateResponse: |
583 | | - """Migrate a session from an external OIDC compliant endpoint. Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. If the response contains a valid email address, Stytch will attempt to match that email address with an existing in your and create a Stytch Session. You will need to create the member before using this endpoint. |
| 645 | + """Migrate a session from an external OIDC compliant endpoint. |
| 646 | + Stytch will call the external UserInfo endpoint defined in your Stytch Project settings in the [Dashboard](https://stytch.com/docs/dashboard), and then perform a lookup using the `session_token`. <!-- FIXME more specific dashboard link--> |
| 647 | + If the response contains a valid email address, Stytch will attempt to match that email address with an existing in your and create a Stytch Session. |
| 648 | + You will need to create the member before using this endpoint. |
584 | 649 |
|
585 | 650 | Fields: |
586 | 651 | - session_token: The authorization token Stytch will pass in to the external userinfo endpoint. |
|
0 commit comments