Skip to content

Commit

Permalink
uses partnerId for auth header to cbs
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettBlox committed May 2, 2024
1 parent 8dba23b commit 0b435d2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions adapters/concert/concert.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server co
}

func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
bidderImpExt, err := getBidderExt(request.Imp[0])
if err != nil {
return nil, []error{fmt.Errorf("get bidder ext: %v", err)}
}

requestJSON, err := json.Marshal(request)
if err != nil {
return nil, []error{err}
Expand All @@ -41,6 +46,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte
requestMap["ext"] = make(map[string]interface{})
}
requestMap["ext"].(map[string]interface{})["adapterVersion"] = adapterVersion
requestMap["ext"].(map[string]interface{})["partnerId"] = bidderImpExt.PartnerId

requestJSON, err = json.Marshal(requestMap)
if err != nil {
Expand All @@ -53,6 +59,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte
Body: requestJSON,
Headers: http.Header{
"Content-Type": []string{"application/json"},
"Authorization": []string{"Bearer " + bidderImpExt.PartnerId},
},
}

Expand Down Expand Up @@ -144,3 +151,14 @@ func getMediaTypeForBid(bid openrtb2.Bid, imp *openrtb2.Imp) (openrtb_ext.BidTyp
Message: fmt.Sprintf("Failed to parse impression \"%s\" mediatype", bid.ImpID),
}
}

func getBidderExt(imp openrtb2.Imp) (bidderImpExt openrtb_ext.ImpExtConcert, err error) {
var impExt adapters.ExtImpBidder
if err = json.Unmarshal(imp.Ext, &impExt); err != nil {
return bidderImpExt, fmt.Errorf("imp ext: %v", err)
}
if err = json.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil {
return bidderImpExt, fmt.Errorf("bidder ext: %v", err)
}
return bidderImpExt, nil
}

0 comments on commit 0b435d2

Please sign in to comment.