Fetch all Buffer channels for the authenticated user. Returns list of channels with id, service, name, displayName, etc.
(access_token: str)
| 102 | # --- Channel (profile) functions --- |
| 103 | |
| 104 | def get_buffer_channels(access_token: str) -> List[Dict]: |
| 105 | """Fetch all Buffer channels for the authenticated user. |
| 106 | |
| 107 | Returns list of channels with id, service, name, displayName, etc. |
| 108 | """ |
| 109 | org_id = get_organization_id(access_token) |
| 110 | if not org_id: |
| 111 | return [] |
| 112 | |
| 113 | result = _graphql_request( |
| 114 | access_token, |
| 115 | GET_CHANNELS_QUERY, |
| 116 | variables={"input": {"organizationId": org_id}}, |
| 117 | ) |
| 118 | |
| 119 | try: |
| 120 | channels = result["data"]["channels"] |
| 121 | return [ch for ch in channels if not ch.get("isDisconnected")] |
| 122 | except (KeyError, TypeError): |
| 123 | return [] |
| 124 | |
| 125 | |
| 126 | def get_channel_by_service(access_token: str, service: str) -> Optional[Dict]: |
no test coverage detected