Discard

Criteo Marketing Solutions API

Questions

Ask A Question
0

how to check x-criteo-hmac-sha512 ,do you have any example

original text: The callback request will also include an HTTP header named x-criteo-hmac-sha512 . Its value will be the HMAC-SHA512 hash of the callback request body, using the same signing secret value as your app. come from url: https://developers.criteo.com/marketing-solutions/docs/criteo-connector-implementation-guide. my callback request body is: {"Type":"ConsentGranted","Data":{"Key":"321*****bdd","Timestamp":1626764122,"State":"63759","ApplicationId":1****,"ApplicationName":"****m","RequestedScopes":[{"AccessLevel":"Read","Domain":"Campaign","CriteoService":"MarketingSolutions"},{"AccessLevel":"Read","Domain":"Audience","CriteoService":"MarketingSolutions"},{"AccessLevel":"Read","Domain":"Analytics","CriteoService":"MarketingSolutions"},{"AccessLevel":"Read","Domain":"Catalog","CriteoService":"MarketingSolutions"}],"AcceptedScopes":[{"AccessLevel":"Read","Domain":"Campaign","CriteoService":"MarketingSolutions"},{"AccessLevel":"Read","Domain":"Audience","CriteoService":"MarketingSolutions"},{"AccessLevel":"Read","Domain":"Analytics","CriteoService":"MarketingSolutions"},{"AccessLevel":"Read","Domain":"Catalog","CriteoService":"MarketingSolutions"}],"Advertisers":[{"Id":"6*****","Name":"M******"}]}} x-criteo-hmac-sha512 value (at HTTP header ) not match with the HMAC-SHA512 hash of upper json .and i don't know what's wrong with this code. my code is below: var criteoHmacSha512 = Request.Headers["x-criteo-hmac-sha512"].ToString(); var requestBody = JsonConvert.SerializeObject(criteoContentCallbackRequestBoday), var requestBodySigned=HmacUtil.Sign(requestBody , Encoding.UTF8.GetBytes(_configInfo.CriteoSigningKeySecret)) if (criteoHmacSha512 != requestBodySigned) { return false; } …… please help me if you know the answer ,thanks a lot

Posted by Laraine Xi 4 days ago

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 16 days ago