File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ type Provider struct {
6363 HTTPClient * http.Client
6464 config * oauth2.Config
6565 providerName string
66+ permissions string
6667}
6768
6869// Name gets the name used to retrieve this provider.
@@ -75,6 +76,11 @@ func (p *Provider) SetName(name string) {
7576 p .providerName = name
7677}
7778
79+ // SetPermissions is to update the bot permissions (used for when ScopeBot is set)
80+ func (p * Provider ) SetPermissions (permissions string ) {
81+ p .permissions = permissions
82+ }
83+
7884func (p * Provider ) Client () * http.Client {
7985 return goth .HTTPClientWithFallBack (p .HTTPClient )
8086}
@@ -84,11 +90,17 @@ func (p *Provider) Debug(debug bool) {}
8490
8591// BeginAuth asks Discord for an authentication end-point.
8692func (p * Provider ) BeginAuth (state string ) (goth.Session , error ) {
87- url := p . config . AuthCodeURL (
88- state ,
93+
94+ opts := []oauth2. AuthCodeOption {
8995 oauth2 .AccessTypeOnline ,
9096 oauth2 .SetAuthURLParam ("prompt" , "none" ),
91- )
97+ }
98+
99+ if p .permissions != "" {
100+ opts = append (opts , oauth2 .SetAuthURLParam ("permissions" , p .permissions ))
101+ }
102+
103+ url := p .config .AuthCodeURL (state , opts ... )
92104
93105 s := & Session {
94106 AuthURL : url ,
You can’t perform that action at this time.
0 commit comments