Log error if Heroku API req responds with non-200-range code
parent
32632f5790
commit
03e966a44a
|
@ -2,6 +2,7 @@ package oauth2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/influxdata/chronograf"
|
"github.com/influxdata/chronograf"
|
||||||
|
@ -65,6 +66,15 @@ func (h *Heroku) PrincipalID(provider *http.Client) (string, error) {
|
||||||
// Requests fail to Heroku unless this Accept header is set.
|
// Requests fail to Heroku unless this Accept header is set.
|
||||||
req.Header.Set("Accept", "application/vnd.heroku+json; version=3")
|
req.Header.Set("Accept", "application/vnd.heroku+json; version=3")
|
||||||
resp, err := provider.Do(req)
|
resp, err := provider.Do(req)
|
||||||
|
if resp.StatusCode/100 != 2 {
|
||||||
|
err := fmt.Errorf(
|
||||||
|
"Unable to GET user data from %s. Status: %s",
|
||||||
|
HerokuAccountRoute,
|
||||||
|
resp.Status,
|
||||||
|
)
|
||||||
|
h.Logger.Error("", err)
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.Logger.Error("Unable to communicate with Heroku. err:", err)
|
h.Logger.Error("Unable to communicate with Heroku. err:", err)
|
||||||
return "", err
|
return "", err
|
||||||
|
|
Loading…
Reference in New Issue