Compare commits
No commits in common. "8ef9e314460f60840c45976c800f1552f6e4d323" and "05d7c498c3f6ee70e65d23504764892d76ca38b1" have entirely different histories.
8ef9e31446
...
05d7c498c3
|
|
@ -21,13 +21,11 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/garyburd/redigo/redis"
|
||||
|
|
@ -162,21 +160,7 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
reqData.Set("code", code)
|
||||
reqData.Set("client_id", sess.ClientID)
|
||||
reqData.Set("redirect_uri", sess.RedirectURI)
|
||||
|
||||
// resp, err := http.PostForm(sess.AuthorizationEndpoint, reqData)
|
||||
req, err := http.NewRequest(http.MethodPost, sess.AuthorizationEndpoint, strings.NewReader(reqData.Encode()))
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "ERROR: %q\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
req.Header.Add("Accept", "application/json")
|
||||
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
log.Println(req)
|
||||
|
||||
client := http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
resp, err := http.PostForm(sess.AuthorizationEndpoint, reqData)
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "ERROR: %q\n", err)
|
||||
return
|
||||
|
|
@ -184,8 +168,7 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == 200 {
|
||||
input := io.TeeReader(resp.Body, os.Stderr)
|
||||
dec := json.NewDecoder(input)
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
var authResponse authResponse
|
||||
err = dec.Decode(&authResponse)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user