-
Notifications
You must be signed in to change notification settings - Fork 3
/
implicit.go
38 lines (34 loc) · 1.04 KB
/
implicit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package disgoauth
// Import fmt package
import "fmt"
// The implicitOAuth() function uses the implicit
// and less-safe response type for getting the
// users access token
func (dc *Client) implicitOAuth() string {
// Return the OAuth URL to a formatted string
// that contains the client id, redirect uri,
// and response type.
return fmt.Sprintf(
"https://discord.com/api/oauth2/authorize?client_id=%s&redirect_uri=%s&response_type=token",
dc.ClientID,
dc.RedirectURI,
)
}
// The nonImplicitOAuth() function uses the default and
// safer response type for getting the users access token
func (dc *Client) nonImplicitOAuth() string {
// Establish the prompt parameter
var prompt string = dc.Prompt
if len(dc.Prompt) > 0 {
prompt = "&prompt=" + dc.Prompt
}
// Return the OAuth URL to a formatted string
// that contains the client id, redirect uri,
// and response type.
return fmt.Sprintf(
"https://discord.com/api/oauth2/authorize?client_id=%s&redirect_uri=%s&response_type=code%s",
dc.ClientID,
dc.RedirectURI,
prompt,
)
}