Skip to content

Commit 8e32e74

Browse files
committed
feat: Add/update new scopes from docs
1 parent 20d4a8a commit 8e32e74

File tree

2 files changed

+72
-21
lines changed

2 files changed

+72
-21
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
[Commits](https://github.com/twitch-rs/twitch_oauth2/compare/v0.17.0...Unreleased)
88

9+
- Added `ChannelManageClips`, `EditorManageClips`, and `ModeratorManageSuspiciousUsers` to `Scopes`
10+
911
## [v0.17.0] - 2026-03-04
1012

1113
### Breaking

src/scopes.rs

Lines changed: 70 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,21 @@ macro_rules! scope_impls {
136136
#[test]
137137
#[cfg(test)]
138138
fn sorted() {
139+
// Deprecated items come at the end, ignore them.
140+
let n_deprecated = [$(
141+
$(stringify!($depr),)*
142+
)*].len();
139143
let slice = [$(
140144
$(#[cfg($cfg)])*
141145
$rename,
142146
)*];
147+
let n_scopes = slice.len();
148+
let slice = &slice[..(n_scopes - n_deprecated)];
143149
let mut slice_sorted = [$(
144150
$(#[cfg($cfg)])*
145151
$rename,
146152
)*];
153+
let slice_sorted = &mut slice_sorted[..(n_scopes - n_deprecated)];
147154
slice_sorted.sort();
148155
for (scope, sorted) in slice.iter().zip(slice_sorted.iter()) {
149156
assert_eq!(scope, sorted);
@@ -153,14 +160,50 @@ macro_rules! scope_impls {
153160
};
154161
}
155162

163+
/*
164+
Extract from the Twitch docs (https://dev.twitch.tv/docs/authentication/scopes/) by pasting in the DevTools:
165+
166+
copy(
167+
(() => {
168+
let tbl = $$("tbody")
169+
.map((tb) => [...tb.children])
170+
.flat()
171+
.map((tr) => [
172+
tr.children[0].textContent,
173+
tr.children[1].firstChild.textContent.trim(),
174+
])
175+
.map(([name, desc]) => [
176+
name
177+
.split(/[:_-]/)
178+
.map((x) => x[0].toUpperCase() + x.slice(1))
179+
.join("") + ", ",
180+
'scope: "' + name + '", ',
181+
"doc: " + JSON.stringify(desc) + ";",
182+
])
183+
.sort((a, b) => a[0] > b[0]);
184+
let [l0, l1] = tbl.reduce(
185+
(acc, cur) => [
186+
Math.max(acc[0], cur[0].length),
187+
Math.max(acc[1], cur[1].length),
188+
],
189+
[0, 0],
190+
);
191+
return tbl
192+
.map(([a, b, c]) => ` ${a.padRight(l0, " ")}${b.padRight(l1, " ")}${c}`)
193+
.join("\n");
194+
})(),
195+
);
196+
*/
197+
156198
scope_impls!(
157199
AnalyticsReadExtensions, scope: "analytics:read:extensions", doc: "View analytics data for the Twitch Extensions owned by the authenticated account.";
158200
AnalyticsReadGames, scope: "analytics:read:games", doc: "View analytics data for the games owned by the authenticated account.";
159201
BitsRead, scope: "bits:read", doc: "View Bits information for a channel.";
160-
ChannelBot, scope: "channel:bot", doc: "Allows the client’s bot users access to a channel.";
202+
ChannelBot, scope: "channel:bot", doc: "Joins your channel’s chatroom as a bot user, and perform chat-related actions as that user.";
161203
ChannelEditCommercial, scope: "channel:edit:commercial", doc: "Run commercials on a channel.";
162204
ChannelManageAds, scope: "channel:manage:ads", doc: "Manage ads schedule on a channel.";
163205
ChannelManageBroadcast, scope: "channel:manage:broadcast", doc: "Manage a channel’s broadcast configuration, including updating channel configuration and managing stream markers and stream tags.";
206+
ChannelManageClips, scope: "channel:manage:clips", doc: "Manage Clips for a channel.";
164207
ChannelManageExtensions, scope: "channel:manage:extensions", doc: "Manage a channel’s Extension configuration, including activating Extensions.";
165208
ChannelManageGuestStar, scope: "channel:manage:guest_star", doc: "Manage Guest Star for your channel.";
166209
ChannelManageModerators, scope: "channel:manage:moderators", doc: "Add or remove the moderator role from users in your channel.";
@@ -171,7 +214,7 @@ scope_impls!(
171214
ChannelManageSchedule, scope: "channel:manage:schedule", doc: "Manage a channel’s stream schedule.";
172215
ChannelManageVideos, scope: "channel:manage:videos", doc: "Manage a channel’s videos, including deleting videos.";
173216
ChannelManageVips, scope: "channel:manage:vips", doc: "Add or remove the VIP role from users in your channel.";
174-
ChannelModerate, scope: "channel:moderate", doc: "Perform moderation actions in a channel. The user requesting the scope must be a moderator in the channel.";
217+
ChannelModerate, scope: "channel:moderate", doc: "Perform moderation actions in a channel.";
175218
ChannelReadAds, scope: "channel:read:ads", doc: "Read the ads schedule and details on your channel.";
176219
ChannelReadCharity, scope: "channel:read:charity", doc: "Read charity campaign details and user donations on your channel.";
177220
ChannelReadEditors, scope: "channel:read:editors", doc: "View a list of users with the editor role for a channel.";
@@ -184,24 +227,24 @@ scope_impls!(
184227
ChannelReadStreamKey, scope: "channel:read:stream_key", doc: "View an authorized user’s stream key.";
185228
ChannelReadSubscriptions, scope: "channel:read:subscriptions", doc: "View a list of all subscribers to a channel and check if a user is subscribed to a channel.";
186229
ChannelReadVips, scope: "channel:read:vips", doc: "Read the list of VIPs in your channel.";
187-
#[deprecated(note = "Use `ChannelReadSubscriptions` (`channel:read:subscriptions`) instead")]
188-
ChannelSubscriptions, scope: "channel_subscriptions", doc: "Read all subscribers to your channel.";
189-
ChatEdit, scope: "chat:edit", doc: "Send live stream chat and rooms messages.";
190-
ChatRead, scope: "chat:read", doc: "View live stream chat and rooms messages.";
230+
ChatEdit, scope: "chat:edit", doc: "Send chat messages to a chatroom using an IRC connection.";
231+
ChatRead, scope: "chat:read", doc: "View chat messages sent in a chatroom using an IRC connection.";
191232
ClipsEdit, scope: "clips:edit", doc: "Manage Clips for a channel.";
233+
EditorManageClips, scope: "editor:manage:clips", doc: "Manage Clips as an editor.";
192234
ModerationRead, scope: "moderation:read", doc: "View a channel’s moderation data including Moderators, Bans, Timeouts, and Automod settings.";
193235
ModeratorManageAnnouncements, scope: "moderator:manage:announcements", doc: "Send announcements in channels where you have the moderator role.";
194236
ModeratorManageAutoMod, scope: "moderator:manage:automod", doc: "Manage messages held for review by AutoMod in channels where you are a moderator.";
195-
ModeratorManageAutomodSettings, scope: "moderator:manage:automod_settings", doc: "Manage a broadcaster’s AutoMod settings";
237+
ModeratorManageAutomodSettings, scope: "moderator:manage:automod_settings", doc: "Manage a broadcaster’s AutoMod settings.";
196238
ModeratorManageBannedUsers, scope: "moderator:manage:banned_users", doc: "Ban and unban users.";
197239
ModeratorManageBlockedTerms, scope: "moderator:manage:blocked_terms", doc: "Manage a broadcaster’s list of blocked terms.";
198240
ModeratorManageChatMessages, scope: "moderator:manage:chat_messages", doc: "Delete chat messages in channels where you have the moderator role";
199-
ModeratorManageChatSettings, scope: "moderator:manage:chat_settings", doc: "View a broadcaster’s chat room settings.";
241+
ModeratorManageChatSettings, scope: "moderator:manage:chat_settings", doc: "Manage a broadcaster’s chat room settings.";
200242
ModeratorManageGuestStar, scope: "moderator:manage:guest_star", doc: "Manage Guest Star for channels where you are a Guest Star moderator.";
201243
ModeratorManageShieldMode, scope: "moderator:manage:shield_mode", doc: "Manage a broadcaster’s Shield Mode status.";
202244
ModeratorManageShoutouts, scope: "moderator:manage:shoutouts", doc: "Manage a broadcaster’s shoutouts.";
245+
ModeratorManageSuspiciousUsers, scope: "moderator:manage:suspicious_users", doc: "Manage suspicious user statuses in channels where the user has the moderator role.";
203246
ModeratorManageUnbanRequests, scope: "moderator:manage:unban_requests", doc: "Manage a broadcaster’s unban requests.";
204-
ModeratorManageWarnings, scope: "moderator:manage:warnings", doc: "Manage a broadcaster’s chat warnings.";
247+
ModeratorManageWarnings, scope: "moderator:manage:warnings", doc: "Warn users in channels where you have the moderator role.";
205248
ModeratorReadAutomodSettings, scope: "moderator:read:automod_settings", doc: "View a broadcaster’s AutoMod settings.";
206249
ModeratorReadBannedUsers, scope: "moderator:read:banned_users", doc: "Read the list of bans or unbans in channels where you have the moderator role.";
207250
ModeratorReadBlockedTerms, scope: "moderator:read:blocked_terms", doc: "View a broadcaster’s list of blocked terms.";
@@ -213,30 +256,36 @@ scope_impls!(
213256
ModeratorReadModerators, scope: "moderator:read:moderators", doc: "Read the list of moderators in channels where you have the moderator role.";
214257
ModeratorReadShieldMode, scope: "moderator:read:shield_mode", doc: "View a broadcaster’s Shield Mode status.";
215258
ModeratorReadShoutouts, scope: "moderator:read:shoutouts", doc: "View a broadcaster’s shoutouts.";
216-
ModeratorReadSuspiciousUsers, scope: "moderator:read:suspicious_users", doc: "Read chat messages from suspicious users and see users flagged as suspicious in channels where you have the moderator role.";
259+
ModeratorReadSuspiciousUsers, scope: "moderator:read:suspicious_users", doc: "Read chat messages from suspicious users and see users flagged as suspicious in channels where the user has the moderator role.";
217260
ModeratorReadUnbanRequests, scope: "moderator:read:unban_requests", doc: "View a broadcaster’s unban requests.";
218261
ModeratorReadVips, scope: "moderator:read:vips", doc: "Read the list of VIPs in channels where you have the moderator role.";
219-
ModeratorReadWarnings, scope: "moderator:read:warnings", doc: "View a broadcaster’s chat warnings.";
220-
UserBot, scope: "user:bot", doc: "Allows client’s bot to act as this user.";
262+
ModeratorReadWarnings, scope: "moderator:read:warnings", doc: "Read warnings in channels where you have the moderator role.";
263+
UserBot, scope: "user:bot", doc: "Join a specified chat channel as your user and appear as a bot, and perform chat-related actions as your user.";
221264
UserEdit, scope: "user:edit", doc: "Manage a user object.";
222-
UserEditBroadcast, scope: "user:edit:broadcast", doc: "Edit your channel's broadcast configuration, including extension configuration. (This scope implies user:read:broadcast capability.)";
223-
#[deprecated(note = "Not used anymore, see https://discuss.dev.twitch.tv/t/deprecation-of-create-and-delete-follows-api-endpoints/32351")]
224-
UserEditFollows, scope: "user:edit:follows", doc: "\\[DEPRECATED\\] Was previously used for “Create User Follows” and “Delete User Follows.";
265+
UserEditBroadcast, scope: "user:edit:broadcast", doc: "View and edit a user’s broadcasting configuration, including Extension configurations.";
225266
UserManageBlockedUsers, scope: "user:manage:blocked_users", doc: "Manage the block list of a user.";
226-
UserManageChatColor, scope: "user:manage:chat_color", doc: "Update the color used for the user’s name in chat.Update User Chat Color";
227-
UserManageWhispers, scope: "user:manage:whispers", doc: "Read whispers that you send and receive, and send whispers on your behalf.";
267+
UserManageChatColor, scope: "user:manage:chat_color", doc: "Update the color used for the user’s name in chat.";
268+
UserManageWhispers, scope: "user:manage:whispers", doc: "Receive whispers sent to your user, and send whispers on your user’s behalf.";
228269
UserReadBlockedUsers, scope: "user:read:blocked_users", doc: "View the block list of a user.";
229270
UserReadBroadcast, scope: "user:read:broadcast", doc: "View a user’s broadcasting configuration, including Extension configurations.";
230-
UserReadChat, scope: "user:read:chat", doc: "View live stream chat and room messages.";
271+
UserReadChat, scope: "user:read:chat", doc: "Receive chatroom messages and informational notifications relating to a channel’s chatroom.";
231272
UserReadEmail, scope: "user:read:email", doc: "View a user’s email address.";
232273
UserReadEmotes, scope: "user:read:emotes", doc: "View emotes available to a user";
233274
UserReadFollows, scope: "user:read:follows", doc: "View the list of channels a user follows.";
234275
UserReadModeratedChannels, scope: "user:read:moderated_channels", doc: "Read the list of channels you have moderator privileges in.";
235276
UserReadSubscriptions, scope: "user:read:subscriptions", doc: "View if an authorized user is subscribed to specific channels.";
236277
UserReadWhispers, scope: "user:read:whispers", doc: "Receive whispers sent to your user.";
237-
UserWriteChat, scope: "user:write:chat", doc: "Send messages in a chat room.";
238-
WhispersEdit, scope: "whispers:edit", doc: "Send whisper messages.";
239-
WhispersRead, scope: "whispers:read", doc: "View your whisper messages.";
278+
UserWriteChat, scope: "user:write:chat", doc: "Send chat messages to a chatroom.";
279+
WhispersRead, scope: "whispers:read", doc: "Receive whisper messages for your user using PubSub.";
280+
281+
// Deprecated/removed scopes:
282+
283+
#[deprecated(note = "Use `ChannelReadSubscriptions` (`channel:read:subscriptions`) instead")]
284+
ChannelSubscriptions, scope: "channel_subscriptions", doc: "Read all subscribers to your channel.";
285+
#[deprecated(note = "Not used anymore, see https://discuss.dev.twitch.tv/t/deprecation-of-create-and-delete-follows-api-endpoints/32351")]
286+
UserEditFollows, scope: "user:edit:follows", doc: "\\[DEPRECATED\\] Was previously used for “Create User Follows” and “Delete User Follows.";
287+
#[deprecated(note = "Use `UserManageWhispers` (`user:manage:whispers`) instead")]
288+
WhispersEdit, scope: "whispers:edit", doc: "\\[DEPRECATED\\] Send whisper messages.";
240289
);
241290

242291
impl Scope {

0 commit comments

Comments
 (0)