|
9 | 9 | from typing import Any, Dict, Optional
|
10 | 10 |
|
11 | 11 | from stytch.b2b.models.organizations_members_oauth_providers import (
|
| 12 | + GithubResponse, |
12 | 13 | GoogleResponse,
|
| 14 | + HubspotResponse, |
13 | 15 | MicrosoftResponse,
|
| 16 | + SlackResponse, |
14 | 17 | )
|
15 | 18 | from stytch.core.api_base import ApiBase
|
16 | 19 | from stytch.core.http.client import AsyncClient, SyncClient
|
@@ -155,3 +158,173 @@ async def microsoft_async(
|
155 | 158 | )
|
156 | 159 | res = await self.async_client.get(url, data, headers)
|
157 | 160 | 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