@@ -3,6 +3,9 @@ package auth
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "maps"
7
+ "slices"
8
+ "sort"
6
9
"strings"
7
10
"sync"
8
11
"time"
@@ -17,6 +20,99 @@ import (
17
20
18
21
type OAuthHandler func (context.Context , oauthhandler.OAuthHandlerArgument ) error
19
22
23
+ func getScopes () []string {
24
+ scopes := map [string ]struct {}{
25
+ "chat:read" : {},
26
+ "chat:edit" : {},
27
+
28
+ "analytics:read:extensions" : {},
29
+ "analytics:read:games" : {},
30
+
31
+ "bits:read" : {},
32
+
33
+ "channel:bot" : {},
34
+ "channel:manage:ads" : {},
35
+ "channel:read:ads" : {},
36
+ "channel:manage:broadcast" : {},
37
+ "channel:read:charity" : {},
38
+ "channel:edit:commercial" : {},
39
+ "channel:read:editors" : {},
40
+ "channel:manage:extensions" : {},
41
+ "channel:read:goals" : {},
42
+ "channel:read:guest_star" : {},
43
+ "channel:manage:guest_star" : {},
44
+ "channel:read:hype_train" : {},
45
+ "channel:manage:moderators" : {},
46
+ "channel:read:polls" : {},
47
+ "channel:manage:polls" : {},
48
+ "channel:read:predictions" : {},
49
+ "channel:manage:predictions" : {},
50
+ "channel:manage:raids" : {},
51
+ "channel:read:redemptions" : {},
52
+ "channel:manage:redemptions" : {},
53
+ "channel:manage:schedule" : {},
54
+ "channel:read:stream_key" : {},
55
+ "channel:read:subscriptions" : {},
56
+ "channel:manage:videos" : {},
57
+ "channel:read:vips" : {},
58
+ "channel:manage:vips" : {},
59
+ "channel:moderate" : {},
60
+
61
+ "clips:edit" : {},
62
+
63
+ "moderation:read" : {},
64
+
65
+ "moderator:manage:announcements" : {},
66
+ "moderator:manage:automod" : {},
67
+ "moderator:read:automod_settings" : {},
68
+ "moderator:manage:automod_settings" : {},
69
+ "moderator:read:banned_users" : {},
70
+ "moderator:manage:banned_users" : {},
71
+ "moderator:read:blocked_terms" : {},
72
+ "moderator:read:chat_messages" : {},
73
+ "moderator:manage:blocked_terms" : {},
74
+ "moderator:manage:chat_messages" : {},
75
+ "moderator:read:chat_settings" : {},
76
+ "moderator:manage:chat_settings" : {},
77
+ "moderator:read:chatters" : {},
78
+ "moderator:read:followers" : {},
79
+ "moderator:read:guest_star" : {},
80
+ "moderator:manage:guest_star" : {},
81
+ "moderator:read:moderators" : {},
82
+ "moderator:read:shield_mode" : {},
83
+ "moderator:manage:shield_mode" : {},
84
+ "moderator:read:shoutouts" : {},
85
+ "moderator:manage:shoutouts" : {},
86
+ "moderator:read:suspicious_users" : {},
87
+ "moderator:read:unban_requests" : {},
88
+ "moderator:manage:unban_requests" : {},
89
+ "moderator:read:vips" : {},
90
+ "moderator:read:warnings" : {},
91
+ "moderator:manage:warnings" : {},
92
+
93
+ "user:bot" : {},
94
+ "user:edit" : {},
95
+ "user:edit:broadcast" : {},
96
+ "user:read:blocked_users" : {},
97
+ "user:manage:blocked_users" : {},
98
+ "user:read:broadcast" : {},
99
+ "user:read:chat" : {},
100
+ "user:manage:chat_color" : {},
101
+ "user:read:email" : {},
102
+ "user:read:emotes" : {},
103
+ "user:read:follows" : {},
104
+ "user:read:moderated_channels" : {},
105
+ "user:read:subscriptions" : {},
106
+ "user:read:whispers" : {},
107
+ "user:manage:whispers" : {},
108
+ "user:write:chat" : {},
109
+ }
110
+
111
+ scopesStrings := slices .Collect (maps .Keys (scopes ))
112
+ sort .Strings (scopesStrings )
113
+ return scopesStrings
114
+ }
115
+
20
116
func NewClientCode (
21
117
ctx context.Context ,
22
118
clientID string ,
@@ -69,14 +165,7 @@ func NewClientCode(
69
165
authURL := GetAuthorizationURL (
70
166
& helix.AuthorizationURLParams {
71
167
ResponseType : "code" , // or "token"
72
- Scopes : []string {
73
- "user:read:chat" ,
74
- "chat:read" ,
75
- "chat:edit" ,
76
- "channel:manage:broadcast" ,
77
- "moderator:manage:chat_messages" ,
78
- "moderator:manage:banned_users" ,
79
- },
168
+ Scopes : getScopes (),
80
169
},
81
170
clientID ,
82
171
RedirectURI (listenPort ),
0 commit comments