From 28b6efc18cbf291f70e2fbeadba8a0ff89a99c5b Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Fri, 27 Jul 2018 13:29:31 -0600 Subject: [PATCH] Fix user impersonation requests --- 3.0/connectwise/requests.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/3.0/connectwise/requests.go b/3.0/connectwise/requests.go index 70cdaeb..d3268d8 100644 --- a/3.0/connectwise/requests.go +++ b/3.0/connectwise/requests.go @@ -80,9 +80,12 @@ func (req *Request) Do() error { if req.CW.AuthAPIKey != "" { httpreq.Header.Set("Authorization", req.CW.AuthAPIKey) } else { //User impersonation - httpreq.Header.Set("Cookie", fmt.Sprintf("companyName=%s", req.CW.CompanyName)) - httpreq.Header.Set("Cookie", fmt.Sprintf("memberHash=%s", req.CW.AuthMemberHash)) - httpreq.Header.Set("Cookie", fmt.Sprintf("MemberID=%s", req.CW.AuthUsername)) + cookieCompanyName := http.Cookie{Name: "companyName", Value: req.CW.CompanyName} + cookieMemberHash := http.Cookie{Name: "memberHash", Value: req.CW.AuthMemberHash} + cookieMemberID := http.Cookie{Name: "memberID", Value: req.CW.AuthUsername} + httpreq.AddCookie(&cookieCompanyName) + httpreq.AddCookie(&cookieMemberHash) + httpreq.AddCookie(&cookieMemberID) } httpreq.Header.Set("Content-Type", "application/json") resp, err := client.Do(httpreq)