return error
parent
0750bedc85
commit
49f49b8b97
|
@ -78,12 +78,17 @@ func (c *Client) Authenticate(username, password string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
resp, err := c.Do(req)
|
resp, err := c.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
return fmt.Errorf("bad authorization: %v", resp.Status)
|
||||||
|
}
|
||||||
|
|
||||||
res := struct {
|
res := struct {
|
||||||
AccessToken string `json:"access_token"`
|
AccessToken string `json:"access_token"`
|
||||||
}{}
|
}{}
|
||||||
|
|
Loading…
Reference in New Issue