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"` }{}