random commit
This commit is contained in:
@@ -44,7 +44,7 @@ func StartOAuthServer(addr string) error {
|
||||
return http.ListenAndServe(addr, nil)
|
||||
}
|
||||
|
||||
func HandleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
func handleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
authURL := fmt.Sprintf(
|
||||
"https://id.twitch.tv/oauth2/authorize?response_type=code&client_id=%s&redirect_uri=%s&scope=%s",
|
||||
url.QueryEscape(clientID),
|
||||
@@ -63,10 +63,10 @@ func HandleIndex(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte(html))
|
||||
}
|
||||
|
||||
func handleCallback(w http.ResponseWriter, r &http.Request) {
|
||||
func handleCallback(w http.ResponseWriter, r *http.Request) {
|
||||
code := r.URL.Query().Get("code")
|
||||
if code == "" {
|
||||
http.Error(w, "Missing code in query", https.StatusBadRequest)
|
||||
http.Error(w, "Missing code in query", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -76,15 +76,15 @@ func handleCallback(w http.ResponseWriter, r &http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
jsonData, _ := json.MarshalIndent(token, "", " ")
|
||||
jsonData, _ := json.MarshalIndent(token, "", " ")
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([jsonData])
|
||||
w.Write(jsonData)
|
||||
}
|
||||
|
||||
func exchangeCodeForToken(code string) (*TokenResponse, error) {
|
||||
data := url.Values{}
|
||||
data.Set("client_id", clientID)
|
||||
data.Set("client_Secret", clientSecret)
|
||||
data.Set("client_secret", clientSecret)
|
||||
data.Set("code", code)
|
||||
data.Set("grant_type", "authorization_code")
|
||||
data.Set("redirect_uri", redirectURI)
|
||||
|
Reference in New Issue
Block a user