fix: strip client ID suffix when passing appId to /oauth/installedLocations
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

GHL_CLIENT_ID has the format "<24-hex-objectid>-<suffix>" but the
installedLocations endpoint expects only the 24-hex MongoDB ObjectId
portion as appId. Strip everything from the first "-" onward.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Head of Product & Engineering 2026-04-06 11:25:11 +02:00
parent 65c1754bab
commit 5be170cf16

View File

@ -293,9 +293,11 @@ func (h *OAuthHandler) getCompanyLocations(ctx context.Context, companyAccessTok
if err != nil { if err != nil {
return nil, err return nil, err
} }
// appId expects the 24-hex MongoDB ObjectId portion of the client ID (before any "-" suffix).
appID := strings.SplitN(h.clientID, "-", 2)[0]
q := req.URL.Query() q := req.URL.Query()
q.Set("companyId", companyID) q.Set("companyId", companyID)
q.Set("appId", h.clientID) q.Set("appId", appID)
q.Set("isInstalled", "true") q.Set("isInstalled", "true")
req.URL.RawQuery = q.Encode() req.URL.RawQuery = q.Encode()
req.Header.Set("Authorization", "Bearer "+companyAccessToken) req.Header.Set("Authorization", "Bearer "+companyAccessToken)