From 49f49b8b97a640931792d7ce243dde459382f9b8 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 14 Apr 2017 17:10:13 +0900 Subject: [PATCH] return error --- mastodon.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mastodon.go b/mastodon.go index 94f6a7b..50ba8a9 100644 --- a/mastodon.go +++ b/mastodon.go @@ -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"` }{}