|
|
@@ -3,7 +3,6 @@ package main |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
|
"io/ioutil" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
|
) |
|
|
@@ -34,7 +33,7 @@ func checkAccess(token string) (bool, error) { |
|
|
|
return false, errors.New("token string is empty") |
|
|
|
} |
|
|
|
// form the request to check the token |
|
|
|
client := &http.Client{} |
|
|
|
client := http.DefaultClient |
|
|
|
req, err := http.NewRequest("GET", indieAuthTokenUrl, nil) |
|
|
|
if err != nil { |
|
|
|
return false, errors.New("error making the request for checking token access") |
|
|
@@ -46,14 +45,10 @@ func checkAccess(token string) (bool, error) { |
|
|
|
if err != nil { |
|
|
|
return false, errors.New("error sending the request for checking token access") |
|
|
|
} |
|
|
|
defer res.Body.Close() |
|
|
|
// parse the response |
|
|
|
body, err := ioutil.ReadAll(res.Body) |
|
|
|
if err != nil { |
|
|
|
return false, errors.New("error parsing the response for checking token access") |
|
|
|
} |
|
|
|
var indieAuthRes = new(IndieAuthRes) |
|
|
|
err = json.Unmarshal(body, &indieAuthRes) |
|
|
|
indieAuthRes := &IndieAuthRes{} |
|
|
|
err = json.NewDecoder(res.Body).Decode(&indieAuthRes) |
|
|
|
res.Body.Close() |
|
|
|
if err != nil { |
|
|
|
return false, errors.New("Error parsing the response into json for checking token access " + err.Error()) |
|
|
|
} |
|
|
|