Discard

Criteo Marketing Solutions API

Questions

Ask A Question
0

python sdk Unauthorized error

We have opened developer account for new maps versions and created and app - we try to do everything as told. The problem is I can get with my credentials from app on: https://developers.criteo.com/marketing-solutions/reference/oauth but when I try same credentials with python sdk i get Unauthorized error. The application build with menager account. This is my code: ############### from criteo_marketing_transition import Configuration import criteo_marketing_transition as cm from datetime import date, timedelta, datetime CRITEO_API_CLIENT_ID: " " CRITEO_API_CLIENT_SECRET:" " GRANT_TYPE: "client_credentials" configuration = Configuration(username=CRITEO_API_CLIENT_ID, password=CRITEO_API_CLIENT_SECRET) client = criteo_marketing_transition.ApiClient(configuration) oauth = criteo_marketing_transition.OAuthApi(client) analytics_api = cm.AnalyticsApi(client) stats_query_message = cm.StatisticsReportQueryMessage(advertiser_ids=, dimensions=["day"], metrics=["AdvertiserCost"], start_date=date.today(), end_date=date.today(), currency="TRY", format="json") [response_content, http_code, response_headers] = analytics_api.get_adset_report_with_http_info(statistics_report_query_message=stats_query_message) ############# This is the Error message: ############# --------------------------------------------------------------------------- ApiException Traceback (most recent call last) <ipython-input-78-2bdaca9b7a37> in <module> 24 # Use the method with 'with_http_info' if you want to retrieve the filename 25 # Otherwise, you can directly call the get_adset_report method ---> 26 [response_content, http_code, response_headers] = analytics_api.get_adset_report_with_http_info(statistics_report_query_message=stats_query_message) /usr/local/lib/python3.9/site-packages/criteo_marketing_transition/api/analytics_api.py in get_adset_report_with_http_info(self, **kwargs) 129 auth_settings = ['Authorization'] # noqa: E501 130 --> 131 return self.api_client.call_api( 132 '/2021-04/statistics/report', 'POST', 133 path_params, /usr/local/lib/python3.9/site-packages/criteo_marketing_transition/api_client.py in call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, async_req, _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host) 334 """ 335 if not async_req: --> 336 return self.__call_api(resource_path, method, 337 path_params, query_params, header_params, 338 body, post_params, files, /usr/local/lib/python3.9/site-packages/criteo_marketing_transition/api_client.py in __call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host) 166 167 # perform request and return response --> 168 response_data = self.request( 169 method, url, query_params=query_params, headers=header_params, 170 post_params=post_params, body=body, /usr/local/lib/python3.9/site-packages/criteo_marketing_transition/api_client.py in request(self, method, url, query_params, headers, post_params, body, _preload_content, _request_timeout) 378 body=body) 379 elif method == "POST": --> 380 return self.rest_client.POST(url, 381 query_params=query_params, 382 headers=headers, /usr/local/lib/python3.9/site-packages/criteo_marketing_transition/rest.py in POST(self, url, headers, query_params, post_params, body, _preload_content, _request_timeout) 279 def POST(self, url, headers=None, query_params=None, post_params=None, 280 body=None, _preload_content=True, _request_timeout=None): --> 281 return self.request("POST", url, 282 headers=headers, 283 query_params=query_params, /usr/local/lib/python3.9/site-packages/criteo_marketing_transition/rest.py in request(self, method, url, query_params, headers, body, post_params, no_auth, _preload_content, _request_timeout) 148 149 if not no_auth: --> 150 self.refresh_token(headers) 151 headers['Authorization'] = 'Bearer ' + self.token.access_token 152 /usr/local/lib/python3.9/site-packages/criteo_marketing_transition/rest.py in refresh_token(self, headers) 313 314 if not missing_credentials and missing_or_expired_token: --> 315 self.token = self.call_auth_endpoint(headers) 316 return True 317 return False /usr/local/lib/python3.9/site-packages/criteo_marketing_transition/rest.py in call_auth_endpoint(self, headers) 338 return Token(data['access_token'], data['expires_in']) 339 except ApiException as e: --> 340 raise self._enrich_exception_message(e, oauth_url) 341 342 @staticmethod /usr/local/lib/python3.9/site-packages/criteo_marketing_transition/rest.py in call_auth_endpoint(self, headers) 327 try: 328 params = [] --> 329 response = self.request("POST", oauth_url, 330 headers=new_headers, 331 query_params=params, /usr/local/lib/python3.9/site-packages/criteo_marketing_transition/rest.py in request(self, method, url, query_params, headers, body, post_params, no_auth, _preload_content, _request_timeout) 238 239 if not 200 <= r.status <= 299: --> 240 raise ApiException(http_resp=r) 241 242 return r ApiException: (401) Reason: Unauthorized HTTP response headers: HTTPHeaderDict({'date': 'Thu, 08 Jul 2021 07:07:55 GMT', 'content-type': 'application/json; charset=utf-8', 'server': 'Kestrel', 'content-length': '213', 'vary': 'Accept-Encoding'}) HTTP response body: {'error': 'invalid_client', 'error_description': "The client authentication failed, the provided client_id doesn't exist or the client_secret is invalid", 'error_uri': 'https://tools.ietf.org/html/rfc6749#section-5.2', 'token_error': "Cannot refresh token by calling 'https://api.criteo.com/oauth2/token'"} ###############

Posted by umar igan 3 months ago

6
ANSWERED

Migration from MAPI to Criteo API

Hello, I am Adam Bako, a developer at Keboola . We are a data operations platform that allows users to connect to data sources and extract/ write data to them as well as provide other functionalities. We have a couple of clients that utilize a Criteo Extractor (extracts/downloads data from Criteo so they can then use this data in Keboola). The Criteo extractor was built by a 3rd party and utilized credentials from "API Users - REST API (Deprecated)" generated in the team page of the Criteo platform. Since it is now depreciated and clients are reporting failures, we are building our own Criteo Extractor using the new authorization flow. From the : The https://developers.criteo.com/marketing-solutions/docs/partner-migration-guide-from-mapi-to-criteo-api it is not exactly clear to me how to proceed. I have been looking into it and am quite confused on what the flow should be like. Do we generate an app and use it to authorize a user and somehow get the client id and client secret from this authorization. If so, are there any resources on how to do this? Also, why is it that only Advertiser Admin can grant or deny access to an application? Or should the clients themselves create apps, authorize them, and use the client id and client secret that can be created in the ""App credentials" of the developer app. Then they provide our extractor app with the client id and client secret, which then downloads the data for them into the platform. Thank you, Adam Bako

Posted by Adam Bako 3 months ago

6
ANSWERED

Failure : statistics report in v20121-01 to return 500

Hello, Since May 12, JST, the following endpoints have been returning statusCode:500 with high frequency. Our processing has been largely unsuccessful. Please let me know when this problem will be resolved. POST https://api.criteo.com/2021-01/statistics/report BODY {"advertiserIds":"XXXXX","startDate":"2021-06-11","endDate":"2021-06-11","dimensions":["AdvertiserId","Day"],"metrics":["Clicks","Displays","ViewableDisplays","NonViewableDisplays","UntrackableDisplays","AdvertiserCost","QualifiedVisits","Visits","CostPerVisit","BounceRate","PotentialDisplays","OverallCompetitionWin","SalesClientAttribution","SalesAllClientAttribution","SalesPc30d","SalesAllPc30d","SalesPv24h","SalesAllPv24h","SalesPc30dPv24h","SalesAllPc30dPv24h","SalesPc1d","SalesAllPc1d","SalesPc7d","SalesAllPc7d","RevenueGeneratedClientAttribution","RevenueGeneratedAllClientAttribution","RevenueGeneratedPc30d","RevenueGeneratedAllPc30d","RevenueGeneratedPv24h","RevenueGeneratedAllPv24h","RevenueGeneratedPc30dPv24h","RevenueGeneratedAllPc30dPv24h","RevenueGeneratedPc1d","RevenueGeneratedAllPc1d","RevenueGeneratedPc7d","RevenueGeneratedAllPc7d","ExposedUsers","Audience","Reach","AverageCartClientAttribution","AverageCartAllClientAttribution","AverageCartPc30d","AverageCartAllPc30d","AverageCartPv24h","AverageCartAllPv24h","AverageCartPc30dPv24h","AverageCartAllPc30dPv24h","AverageCartPc1d","AverageCartAllPc1d","AverageCartPc7d","AverageCartAllPc7d","ClickThroughRate","ConversionRateClientAttribution","ConversionRateAllClientAttribution","ConversionRatePc30d","ConversionRateAllPc30d","ConversionRatePv24h","ConversionRateAllPv24h","ConversionRatePc30dPv24h","ConversionRateAllPc30dPv24h","ConversionRatePc1d","ConversionRateAllPc1d","ConversionRatePc7d","ConversionRateAllPc7d","ECosClientAttribution","ECosAllClientAttribution","ECosPc30d","ECosAllPc30d","ECosPv24h","ECosAllPv24h","ECosPc30dPv24h","ECosAllPc30dPv24h","ECosPc1d","ECosAllPc1d","ECosPc7d","ECosAllPc7d","CostPerOrderClientAttribution","CostPerOrderAllClientAttribution","CostPerOrderPc30d","CostPerOrderAllPc30d","CostPerOrderPv24h","CostPerOrderAllPv24h","CostPerOrderPc30dPv24h","CostPerOrderAllPc30dPv24h","CostPerOrderPc1d","CostPerOrderAllPc1d","CostPerOrderPc7d","CostPerOrderAllPc7d","Cpc","ECpm","RoasClientAttribution","RoasAllClientAttribution","RoasPc30d","RoasAllPc30d","RoasPv24h","RoasAllPv24h","RoasPc30dPv24h","RoasAllPc30dPv24h","RoasPc1d","RoasAllPc1d","RoasPc7d","RoasAllPc7d","AdvertiserValue","AdvertiserAllValue","CostOfAdvertiserValue","CostOfAdvertiserValueAll","PostInstallSales","AppInstalls","PostInstallConversionRate","PostInstallCostOfSale","PostInstallOrderValue","CostPerInstall","InstallRate","PostInstallCostPerOrder","PostInstallRoas","OmnichannelRoasClientAttribution","OmnichannelRoasPc30d","OmnichannelRoasAllPc30d","OmnichannelRoasPv24h","OmnichannelRoasAllPv24h","OmnichannelRevenueClientAttribution","OmnichannelRevenuePc30d","OmnichannelRevenueAllPc30d","OmnichannelRevenuePv24h","OmnichannelRevenueAllPv24h","OmnichannelsalesClientAttribution","OmnichannelSalesPc30d","OmnichannelSalesAllPc30d","OmnichannelSalesPv24h","OmnichannelSalesAllPv24h","RoasOfflinePc30d","RoasOfflinePv24h","SalesOfflinePc30d","SalesOfflinePv24h","RevenueGeneratedOfflinePc30d","RevenueGeneratedOfflinePv24h"],"currency":"JPY","format":"Json","timezone":"UTC +0"}

Posted by Yusuke Aruga 4 months ago

3

Duplicate categoryId=0 records in adset category report

Hello. I have a question about adset category report. The reports we created sometimes has two reocrds under the same dimesion with categoryId=0, with different metrics. The dimesions are as follows: - AdvertiserId, Advertiser, Day, AdsetId, Adset, CategoryId, Category, Device In my uderstanding, the report with these dimensions are supposed to have a unique record under the same dimesions. For example, ----------------------------------------------------------- AdvertiserId, Advertiser, Day, AdsetId, Adset, CategoryId, Category, Device, Clicks, 11111, adv1, 2021-06-10, Adset1, 1111, category1, 11111, Smartphone, 100 11111, adv1, 2021-06-10, Adset1, 1111, category2, 11112, Smartphone, 120 ----------------------------------------------------------- However, sometimes there are two records under the same dimension with categoryId=0 as follows: ----------------------------------------------------------- AdvertiserId, Advertiser, Day, AdsetId, Adset, CategoryId, Category, Device, Clicks, 11111, adv1, 2021-06-10, Adset1, 1111, , 0, Smartphone, 100 11111, adv1, 2021-06-10, Adset1, 1111, , 0, Smartphone, 10 ----------------------------------------------------------- I really appreciate if you cloud tell us how to interpret those two records? Metrics are as follows: Metrics: Clicks,Displays,AdvertiserCost,SalesAllPc30d,SalesPc30d,SalesPv24h,SalesAllPv24h,SalesAllPc30dPv24h,PostInstallSales,AppInstalls,SalesOfflinePc30d,OmnichannelSalesAllPc30d,RoasPc30d,RoasAllPc30d,RoasOfflinePc30d,OmnichannelRoasAllPc30d,RevenueGeneratedAllPc30d,RevenueGeneratedAllPv24h,RevenueGeneratedAllPc30dPv24h,RevenueGeneratedOfflinePc30d,OmnichannelRevenueAllPc30d,AverageCartAllPc30d,ConversionRateAllPc30d,ConversionRateAllPv24h,ClickThroughRate,Cpc,ECpm,ECosAllPc30d,ECosAllPv24h,ECosAllPc30dPv24h,CostPerOrderAllPc30d,CostPerOrderAllPv24h,CostPerOrderAllPc30dPv24h,AdvertiserAllValue,CostOfAdvertiserValueAll,ExposedUsers,OverallCompetitionWin,Audience,Reach,ViewableDisplays,NonViewableDisplays,UntrackableDisplays,BounceRate,PotentialDisplays,QualifiedVisits,Visits,RevenueGeneratedPc30d

Posted by Yasushi Otsuka 4 months ago