Compare commits
5 Commits
05d7c498c3
...
8ef9e31446
Author | SHA1 | Date | |
---|---|---|---|
8ef9e31446 | |||
a8918e59d0 | |||
24a71a6b43 | |||
5aa2c012cd | |||
4df4371256 |
|
@ -21,11 +21,13 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/garyburd/redigo/redis"
|
||||
|
@ -160,7 +162,21 @@ 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)
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "ERROR: %q\n", err)
|
||||
return
|
||||
|
@ -168,7 +184,8 @@ func (h *mainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == 200 {
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
input := io.TeeReader(resp.Body, os.Stderr)
|
||||
dec := json.NewDecoder(input)
|
||||
var authResponse authResponse
|
||||
err = dec.Decode(&authResponse)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user