ms-teams-cli icon indicating copy to clipboard operation
ms-teams-cli copied to clipboard

Default scopes omit `Presence.ReadWrite`, so every presence write returns 403

Open aberoham opened this issue 3 months ago • 0 comments

teams presence set, presence status and presence clear are documented (README.md:415-417, docs/command-reference.md:158-160), but none of them work for a login that falls back to the built-in scope set.

All three Graph calls require the delegated Presence.ReadWrite permission (setPresence, setStatusMessage, clearPresence). DEFAULT_DELEGATED_SCOPES (src/config.rs:11) asks for Presence.Read.All and nothing else from that family, and it is what resolve_delegated_scopes falls back to when no --scopes flag, TEAMS_CLI_SCOPES variable, or profile scopes field is present (src/config.rs:286-295).

$ teams presence set --availability Available --activity Available
{"success": false, "error": {"code": "PERMISSION_DENIED",
  "message": "Permission denied: {\"error\":{\"code\":\"Forbidden\",\"message\":\"\", ... }}"}}

Graph sends an empty message, and the CLI passes the body through without interpretation (src/api/client.rs:579-582, src/output/mod.rs:102-107), so nothing in the output points at the missing scope.

Presence.ReadWrite is not admin-consent-required, so the reason README.md:229-231 gives for keeping ChannelMessage.Read.All out of the defaults does not apply here.

Workaround

--scopes replaces the default set rather than extending it, so the whole string has to be restated:

teams auth login --scopes "User.Read Team.ReadBasic.All Channel.ReadBasic.All ChannelMessage.Send Chat.ReadWrite ChatMessage.Send ChatMessage.Read User.ReadBasic.All Presence.Read.All Presence.ReadWrite offline_access"

presence clear stays broken even with the scope granted, for an unrelated reason — filed separately.

Seen on teams-cli 0.4.0, delegated work-account token.

aberoham avatar Aug 21 '26 21:08 aberoham