Fetch the first organization ID for the authenticated user.
(access_token: str)
| 87 | |
| 88 | |
| 89 | def get_organization_id(access_token: str) -> Optional[str]: |
| 90 | """Fetch the first organization ID for the authenticated user.""" |
| 91 | result = _graphql_request(access_token, GET_ORGANIZATIONS_QUERY) |
| 92 | try: |
| 93 | orgs = result["data"]["account"]["organizations"] |
| 94 | if orgs: |
| 95 | return orgs[0]["id"] |
| 96 | except (KeyError, TypeError, IndexError): |
| 97 | pass |
| 98 | print("No organization found in Buffer account") |
| 99 | return None |
| 100 | |
| 101 | |
| 102 | # --- Channel (profile) functions --- |
no test coverage detected