This commit is contained in:
2023-11-15 12:03:31 +03:00
parent 823dfb49bc
commit a85ad3acd5
4 changed files with 26 additions and 34 deletions

View File

@@ -115,7 +115,7 @@ func (bdc *BVSDecortClient) getToken(ctx context.Context) error {
body := fmt.Sprintf("grant_type=password&client_id=%s&client_secret=%s&username=%s&password=%s&response_type=token&scope=openid", bdc.cfg.AppID, bdc.cfg.AppSecret, bdc.cfg.Username, bdc.cfg.Password)
bodyReader := strings.NewReader(body)
bdc.cfg.SSOURL = strings.TrimSuffix(bdc.cfg.SSOURL, "/")
req, _ := http.NewRequestWithContext(ctx, "POST", bdc.cfg.SSOURL+"/realms/"+bdc.cfg.Domain+"/protocol/openid-connect/token", bodyReader)
@@ -154,20 +154,20 @@ func (bdc *BVSDecortClient) do(req *http.Request, ctype string) (*http.Response,
// var resp *http.Response
// var err error
buf, _ := io.ReadAll(req.Body)
// req = req.Clone(req.Context())
// for i := uint64(0); i < dc.cfg.Retries; i++ {
// for i := uint64(0); i < bdc.cfg.Retries; i++ {
// req = req.Clone(req.Context())
req.Body = io.NopCloser(bytes.NewBuffer(buf))
resp, err := bdc.client.Do(req)
// if err == nil {
if resp.StatusCode == 200 {
return resp, err
if err == nil {
if resp.StatusCode == 200 {
return resp, err
}
}
// }
respBytes, _ := io.ReadAll(resp.Body)
err = fmt.Errorf("%s", respBytes)
resp.Body.Close()
// }
// }
return nil, fmt.Errorf("could not execute request: %w", err)
}