Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: criteo_aud auth_token expire code incorporated #2687

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/v0/destinations/criteo_audience/networkHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ const criteoAudienceRespHandler = (destResponse, stageMsg) => {

// https://developers.criteo.com/marketing-solutions/docs/api-error-types#error-category-types
// to handle the case when authorization-token is invalid
if (status === 401 && matchErrorCode('authorization-token-invalid', response)) {
if (
status === 401 &&
(matchErrorCode('authorization-token-invalid', response) ||
matchErrorCode('authorization-token-expired', response))
) {
throw new NetworkError(
`${response?.errors[0]?.title} ${stageMsg}`,
status,
Expand Down
17 changes: 17 additions & 0 deletions test/__mocks__/data/criteo_audience/proxy_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
"https://api.criteo.com/2022-10/audiences/34894/contactlist": {
"status": 200
},
"https://api.criteo.com/2022-10/audiences/3485/contactlist": {
"code": "400",
"response": {
"data": {
"errors": [
{
"traceIdentifier": "80a1a0ba3981b04da847d05700752c77",
"type": "authorization",
"code": "authorization-token-expired",
"instance": "/2022-10/audiences/123/contactlist",
"title": "The authorization token has expired"
}
]
},
"status": 401
}
},
"https://api.criteo.com/2022-10/audiences/34895/contactlist": {
"code": "400",
"response": {
Expand Down
35 changes: 35 additions & 0 deletions test/__tests__/data/criteo_audience_proxy_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,41 @@
"destination": "criteo_audience"
}
},
{
"version": "1",
"type": "REST",
"method": "PATCH",
"endpoint": "https://api.criteo.com/2022-10/audiences/3485/contactlist",
"headers": {
"Authorization": "Bearer success_access_token",
"Content-Type": "application/json",
"Accept": "application/json"
},
"body": {
"JSON": {
"data": {
"type": "ContactlistAmendment",
"attributes": {
"operation": "add",
"identifierType": "madid",
"identifiers": [
"sample_madid",
"sample_madid_1",
"sample_madid_2"
],
"internalIdentifiers": false
}
}
},
"JSON_ARRAY": {},
"XML": {},
"FORM": {}
},
"files": {},
"params": {
"destination": "criteo_audience"
}
},
{
"version": "1",
"type": "REST",
Expand Down
32 changes: 30 additions & 2 deletions test/__tests__/data/criteo_audience_proxy_output.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
{
{
"output": {
"status": 200,
"message": "Request Processed Successfully",
Expand All @@ -9,6 +9,34 @@
}
}
},
{
"output": {
"status": 401,
"authErrorCategory": "REFRESH_TOKEN",
"destinationResponse": {
"errors": [
{
"traceIdentifier": "80a1a0ba3981b04da847d05700752c77",
"type": "authorization",
"code": "authorization-token-expired",
"instance": "/2022-10/audiences/123/contactlist",
"title": "The authorization token has expired"
}
]
},
"message": "The authorization token has expired during criteo_audience response transformation",
"statTags": {
"destType": "CRITEO_AUDIENCE",
"errorCategory": "network",
"destinationId": "Non-determininable",
"workspaceId": "Non-determininable",
"errorType": "aborted",
"feature": "dataDelivery",
"implementation": "native",
"module": "destination"
}
}
},
{
"output": {
"status": 401,
Expand Down Expand Up @@ -48,7 +76,7 @@
"traceIdentifier": "80a1a0ba3981b04da847d05700752c77",
"type": "authorization"
}
]
]
},
"status": 404
},
Expand Down
Loading