BingAds / BingAds-Python-SDK

Other
116 stars 162 forks source link

BingAds API does not work when using different tenant #283

Open SgtMarmite opened 4 months ago

SgtMarmite commented 4 months ago

Hello,

We have a component (application) for extracting BingAds reports for our platform's users. We have been using bingads SDK for some time and we've had no issues for over a year. We use a separate component for OAuth and in the component itself we use OAuthWithAuthorizationCode for bingads client Authorization. Some time ago one of our clients also wanted to use this component. The only difference is that this client is not using the app registered in our tenant, but the app is registered is their own. This means that we are using their client id and client secret for OAuth and the component, and our developer token and their tenant_id in the component for following requests.

While the OAuth works fine, as they are able to Authorize the component and we get a new token, any following request to the API ends with an error.

This is one of the errors we have received 12 days ago:

SOAP Fault Detail: 
(detail) {
    AdApiFaultDetail = 
    (AdApiFaultDetail) {
        TrackingId = "258af894-e2ec-44ee-bc93-f6c11c2dded7"
        Errors = 
        (Errors) {
            AdApiError = 
            (AdApiError) {
                Code = "105"
                Detail = None
                ErrorCode = "InvalidCredentials"
                Message = "Authentication failed. Either supplied credentials are invalid or the account is inactive"
            }
        }
    }
}

Our code is available publicly, and the Authorization class can be seen here. Could anyone please check if we are using that class correctly in case that tenant_id is set?