return error

pull/7/head
Yasuhiro Matsumoto 2017-04-14 17:10:13 +09:00
parent 0750bedc85
commit 49f49b8b97
1 changed files with 5 additions and 0 deletions

View File

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