Skip to content

Commit d0c020c

Browse files
committed
Adds support for GitHub B2B OAuth
1 parent 3e7155d commit d0c020c

20 files changed

+629
-36
lines changed

stytch/b2b/api/discovery_organizations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def create(
142142
143143
`NOT_ALLOWED` – disable JIT provisioning by OAuth Tenant.
144144
145-
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
145+
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
146146
""" # noqa
147147
headers: Dict[str, str] = {}
148148
data: Dict[str, Any] = {
@@ -310,7 +310,7 @@ async def create_async(
310310
311311
`NOT_ALLOWED` – disable JIT provisioning by OAuth Tenant.
312312
313-
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
313+
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
314314
""" # noqa
315315
headers: Dict[str, str] = {}
316316
data: Dict[str, Any] = {

stytch/b2b/api/oauth_discovery.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def authenticate(
3030
session_custom_claims: Optional[Dict[str, Any]] = None,
3131
pkce_code_verifier: Optional[str] = None,
3232
) -> AuthenticateResponse:
33-
"""Authenticates the Discovery token and exchanges it for an Intermediate Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.
33+
"""Authenticates the Discovery token and exchanges it for an Intermediate
34+
Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.
3435
3536
Fields:
3637
- discovery_oauth_token: The Discovery OAuth token to authenticate.
@@ -68,7 +69,8 @@ async def authenticate_async(
6869
session_custom_claims: Optional[Dict[str, Any]] = None,
6970
pkce_code_verifier: Optional[str] = None,
7071
) -> AuthenticateResponse:
71-
"""Authenticates the Discovery token and exchanges it for an Intermediate Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.
72+
"""Authenticates the Discovery token and exchanges it for an Intermediate
73+
Session Token. Intermediate Session Tokens can be used for various Discovery login flows and are valid for 10 minutes.
7274
7375
Fields:
7476
- discovery_oauth_token: The Discovery OAuth token to authenticate.

stytch/b2b/api/organizations.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def create(
130130
131131
`NOT_ALLOWED` – disable JIT provisioning by OAuth Tenant.
132132
133-
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
133+
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
134134
""" # noqa
135135
headers: Dict[str, str] = {}
136136
data: Dict[str, Any] = {
@@ -266,7 +266,7 @@ async def create_async(
266266
267267
`NOT_ALLOWED` – disable JIT provisioning by OAuth Tenant.
268268
269-
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
269+
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
270270
""" # noqa
271271
headers: Dict[str, str] = {}
272272
data: Dict[str, Any] = {
@@ -478,7 +478,7 @@ def update(
478478
479479
480480
If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.oauth-tenant-jit-provisioning` action on the `stytch.organization` Resource.
481-
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
481+
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
482482
483483
If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-oauth-tenants` action on the `stytch.organization` Resource.
484484
""" # noqa
@@ -666,7 +666,7 @@ async def update_async(
666666
667667
668668
If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.oauth-tenant-jit-provisioning` action on the `stytch.organization` Resource.
669-
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack" and "hubspot".
669+
- allowed_oauth_tenants: A map of allowed OAuth tenants. If this field is not passed in, the Organization will not allow JIT provisioning by OAuth Tenant. Allowed keys are "slack", "hubspot", and "github".
670670
671671
If this field is provided and a session header is passed into the request, the Member Session must have permission to perform the `update.settings.allowed-oauth-tenants` action on the `stytch.organization` Resource.
672672
""" # noqa

stytch/b2b/api/organizations_members.py

+18
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,15 @@ def oidc_providers(
655655
member_id: str,
656656
include_refresh_token: Optional[bool] = None,
657657
) -> OIDCProvidersResponse:
658+
"""Retrieve the saved OIDC access tokens and ID tokens for a member. After a successful OIDC login, Stytch will save the
659+
issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
660+
access token automatically.
661+
662+
Fields:
663+
- organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
664+
- member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
665+
- include_refresh_token: Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
666+
""" # noqa
658667
headers: Dict[str, str] = {}
659668
data: Dict[str, Any] = {
660669
"organization_id": organization_id,
@@ -676,6 +685,15 @@ async def oidc_providers_async(
676685
member_id: str,
677686
include_refresh_token: Optional[bool] = None,
678687
) -> OIDCProvidersResponse:
688+
"""Retrieve the saved OIDC access tokens and ID tokens for a member. After a successful OIDC login, Stytch will save the
689+
issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
690+
access token automatically.
691+
692+
Fields:
693+
- organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
694+
- member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
695+
- include_refresh_token: Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
696+
""" # noqa
679697
headers: Dict[str, str] = {}
680698
data: Dict[str, Any] = {
681699
"organization_id": organization_id,

stytch/b2b/api/organizations_members_oauth_providers.py

+173
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
from typing import Any, Dict, Optional
1010

1111
from stytch.b2b.models.organizations_members_oauth_providers import (
12+
GithubResponse,
1213
GoogleResponse,
14+
HubspotResponse,
1315
MicrosoftResponse,
16+
SlackResponse,
1417
)
1518
from stytch.core.api_base import ApiBase
1619
from stytch.core.http.client import AsyncClient, SyncClient
@@ -155,3 +158,173 @@ async def microsoft_async(
155158
)
156159
res = await self.async_client.get(url, data, headers)
157160
return MicrosoftResponse.from_json(res.response.status, res.json)
161+
162+
def slack(
163+
self,
164+
organization_id: str,
165+
member_id: str,
166+
) -> SlackResponse:
167+
"""Retrieve the saved Slack access token and ID token for a member. After a successful OAuth login, Stytch will save the
168+
issued access token and ID token from the identity provider.
169+
170+
Fields:
171+
- organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
172+
- member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
173+
""" # noqa
174+
headers: Dict[str, str] = {}
175+
data: Dict[str, Any] = {
176+
"organization_id": organization_id,
177+
"member_id": member_id,
178+
}
179+
180+
url = self.api_base.url_for(
181+
"/v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/slack",
182+
data,
183+
)
184+
res = self.sync_client.get(url, data, headers)
185+
return SlackResponse.from_json(res.response.status_code, res.json)
186+
187+
async def slack_async(
188+
self,
189+
organization_id: str,
190+
member_id: str,
191+
) -> SlackResponse:
192+
"""Retrieve the saved Slack access token and ID token for a member. After a successful OAuth login, Stytch will save the
193+
issued access token and ID token from the identity provider.
194+
195+
Fields:
196+
- organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
197+
- member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
198+
""" # noqa
199+
headers: Dict[str, str] = {}
200+
data: Dict[str, Any] = {
201+
"organization_id": organization_id,
202+
"member_id": member_id,
203+
}
204+
205+
url = self.api_base.url_for(
206+
"/v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/slack",
207+
data,
208+
)
209+
res = await self.async_client.get(url, data, headers)
210+
return SlackResponse.from_json(res.response.status, res.json)
211+
212+
def hubspot(
213+
self,
214+
organization_id: str,
215+
member_id: str,
216+
include_refresh_token: Optional[bool] = None,
217+
) -> HubspotResponse:
218+
"""Retrieve the saved Hubspot access token and ID token for a member. After a successful OAuth login, Stytch will save the
219+
issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
220+
access token automatically.
221+
222+
Fields:
223+
- organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
224+
- member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
225+
- include_refresh_token: Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
226+
""" # noqa
227+
headers: Dict[str, str] = {}
228+
data: Dict[str, Any] = {
229+
"organization_id": organization_id,
230+
"member_id": member_id,
231+
}
232+
if include_refresh_token is not None:
233+
data["include_refresh_token"] = include_refresh_token
234+
235+
url = self.api_base.url_for(
236+
"/v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot",
237+
data,
238+
)
239+
res = self.sync_client.get(url, data, headers)
240+
return HubspotResponse.from_json(res.response.status_code, res.json)
241+
242+
async def hubspot_async(
243+
self,
244+
organization_id: str,
245+
member_id: str,
246+
include_refresh_token: Optional[bool] = None,
247+
) -> HubspotResponse:
248+
"""Retrieve the saved Hubspot access token and ID token for a member. After a successful OAuth login, Stytch will save the
249+
issued access token and ID token from the identity provider. If a refresh token has been issued, Stytch will refresh the
250+
access token automatically.
251+
252+
Fields:
253+
- organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
254+
- member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
255+
- include_refresh_token: Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
256+
""" # noqa
257+
headers: Dict[str, str] = {}
258+
data: Dict[str, Any] = {
259+
"organization_id": organization_id,
260+
"member_id": member_id,
261+
}
262+
if include_refresh_token is not None:
263+
data["include_refresh_token"] = include_refresh_token
264+
265+
url = self.api_base.url_for(
266+
"/v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/hubspot",
267+
data,
268+
)
269+
res = await self.async_client.get(url, data, headers)
270+
return HubspotResponse.from_json(res.response.status, res.json)
271+
272+
def github(
273+
self,
274+
organization_id: str,
275+
member_id: str,
276+
include_refresh_token: Optional[bool] = None,
277+
) -> GithubResponse:
278+
"""Retrieve the saved GitHub access token for a Member. After a successful OAuth login, Stytch will save the
279+
issued access token from the identity provider. GitHub does not issue refresh tokens, but will invalidate access
280+
tokens after very long periods of inactivity.
281+
282+
Fields:
283+
- organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
284+
- member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
285+
- include_refresh_token: Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
286+
""" # noqa
287+
headers: Dict[str, str] = {}
288+
data: Dict[str, Any] = {
289+
"organization_id": organization_id,
290+
"member_id": member_id,
291+
}
292+
if include_refresh_token is not None:
293+
data["include_refresh_token"] = include_refresh_token
294+
295+
url = self.api_base.url_for(
296+
"/v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/github",
297+
data,
298+
)
299+
res = self.sync_client.get(url, data, headers)
300+
return GithubResponse.from_json(res.response.status_code, res.json)
301+
302+
async def github_async(
303+
self,
304+
organization_id: str,
305+
member_id: str,
306+
include_refresh_token: Optional[bool] = None,
307+
) -> GithubResponse:
308+
"""Retrieve the saved GitHub access token for a Member. After a successful OAuth login, Stytch will save the
309+
issued access token from the identity provider. GitHub does not issue refresh tokens, but will invalidate access
310+
tokens after very long periods of inactivity.
311+
312+
Fields:
313+
- organization_id: Globally unique UUID that identifies a specific Organization. The `organization_id` is critical to perform operations on an Organization, so be sure to preserve this value.
314+
- member_id: Globally unique UUID that identifies a specific Member. The `member_id` is critical to perform operations on a Member, so be sure to preserve this value.
315+
- include_refresh_token: Whether to return the refresh token Stytch has stored for the OAuth Provider. Defaults to false. **Important:** If your application exchanges the refresh token, Stytch may not be able to automatically refresh access tokens in the future.
316+
""" # noqa
317+
headers: Dict[str, str] = {}
318+
data: Dict[str, Any] = {
319+
"organization_id": organization_id,
320+
"member_id": member_id,
321+
}
322+
if include_refresh_token is not None:
323+
data["include_refresh_token"] = include_refresh_token
324+
325+
url = self.api_base.url_for(
326+
"/v1/b2b/organizations/{organization_id}/members/{member_id}/oauth_providers/github",
327+
data,
328+
)
329+
res = await self.async_client.get(url, data, headers)
330+
return GithubResponse.from_json(res.response.status, res.json)

0 commit comments

Comments
 (0)