Working download photo method

Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
Kris Nóva 2021-02-09 18:25:46 -08:00
parent c1a45bf8e3
commit b7fd487a2e
18 changed files with 918 additions and 170 deletions

View file

@ -124,11 +124,25 @@ func (c *Client) LoginV1() error {
}
return fmt.Errorf("login error [%d] %s", resp.StatusCode, body)
}
// --- JSON Auth Response on to Options ---
cfg := &Config{
Config: &Options{},
}
bytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("unable to parse auth body: %v", err)
}
err = json.Unmarshal(bytes, &cfg)
if err != nil {
return fmt.Errorf("unable to json unmarshal auth body: %v", err)
}
token := resp.Header.Get(APIAuthHeaderKey)
if token == "" {
return fmt.Errorf("missing auth token from successful login")
}
c.v1client = v1.New(c.connectionURL, token)
c.v1client = v1.New(c.connectionURL, token, cfg.Config.DownloadToken)
return nil
}