From 30d585a9569d27a77ddfbee8a2a2b67c97d105e7 Mon Sep 17 00:00:00 2001 From: gvidoou Date: Fri, 15 Nov 2024 15:30:54 +0200 Subject: [PATCH 1/2] Create stape api url from headers --- template.js | 13 +++------ template.tpl | 82 +++++++++++++++++++++++++++++++--------------------- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/template.js b/template.js index 3f2e501..9677ebe 100644 --- a/template.js +++ b/template.js @@ -128,19 +128,14 @@ function getUrl() { ); } - const containerKey = data.containerKey.split(':'); - const containerZone = containerKey[0]; - const containerIdentifier = containerKey[1]; - const containerApiKey = containerKey[2]; - const containerDefaultDomainEnd = containerKey[3] || 'io'; - + const containerIdentifier = getRequestHeader('x-gtm-identifier'); + const defaultDomain = getRequestHeader('x-gtm-default-domain'); + const containerApiKey = getRequestHeader('x-gtm-api-key'); return ( 'https://' + enc(containerIdentifier) + '.' + - enc(containerZone) + - '.stape.' + - enc(containerDefaultDomainEnd) + + enc(defaultDomain) + '/stape-api/' + enc(containerApiKey) + '/v2/gads/auth-proxy' diff --git a/template.tpl b/template.tpl index b4335ff..6aaafa2 100644 --- a/template.tpl +++ b/template.tpl @@ -124,30 +124,6 @@ ___TEMPLATE_PARAMETERS___ } ], "help": "The process of obtaining Google Ads API Developer token is pretty complicated. If you use Stape hosting, your requests will be signed with Stape\u0027s Developer Token. If you use other hosting or you have your own Developer Token, you can override it. \u003cbr\u003e\u003cbr\u003e \u003ca href\u003d\"https://developers.google.com/google-ads/api/docs/first-call/dev-token\" target\u003d\"_blank\"\u003eMore info about developer tokens.\u003c/a\u003e" - }, - { - "type": "TEXT", - "name": "containerKey", - "displayName": "Stape Container API Key", - "simpleValueType": true, - "valueValidators": [ - { - "type": "NON_EMPTY" - } - ], - "enablingConditions": [ - { - "paramName": "developerTokenOwn", - "paramValue": false, - "type": "EQUALS" - }, - { - "paramName": "authFlow", - "paramValue": "stape", - "type": "EQUALS" - } - ], - "help": "It can be found in the detailed view of the container inside your \u003ca href\u003d\"https://app.stape.io/container/\" target\u003d\"_blank\"\u003eStape account\u003c/a\u003e." } ] }, @@ -663,19 +639,14 @@ function getUrl() { ); } - const containerKey = data.containerKey.split(':'); - const containerZone = containerKey[0]; - const containerIdentifier = containerKey[1]; - const containerApiKey = containerKey[2]; - const containerDefaultDomainEnd = containerKey[3] || 'io'; - + const containerIdentifier = getRequestHeader('x-gtm-identifier'); + const defaultDomain = getRequestHeader('x-gtm-default-domain'); + const containerApiKey = getRequestHeader('x-gtm-api-key'); return ( 'https://' + enc(containerIdentifier) + '.' + - enc(containerZone) + - '.stape.' + - enc(containerDefaultDomainEnd) + + enc(defaultDomain) + '/stape-api/' + enc(containerApiKey) + '/v2/gads/auth-proxy' @@ -1232,6 +1203,51 @@ ___SERVER_PERMISSIONS___ "string": "trace-id" } ] + }, + { + "type": 3, + "mapKey": [ + { + "type": 1, + "string": "headerName" + } + ], + "mapValue": [ + { + "type": 1, + "string": "x-gtm-identifier" + } + ] + }, + { + "type": 3, + "mapKey": [ + { + "type": 1, + "string": "headerName" + } + ], + "mapValue": [ + { + "type": 1, + "string": "x-gtm-default-domain" + } + ] + }, + { + "type": 3, + "mapKey": [ + { + "type": 1, + "string": "headerName" + } + ], + "mapValue": [ + { + "type": 1, + "string": "x-gtm-api-key" + } + ] } ] } From 4d9ccf0eee11449ebfd0266808c4c3bfa230ce94 Mon Sep 17 00:00:00 2001 From: gvidoou Date: Fri, 15 Nov 2024 16:12:44 +0200 Subject: [PATCH 2/2] updated metadata --- metadata.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metadata.yaml b/metadata.yaml index a626f70..b84cdd1 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -1,5 +1,7 @@ homepage: "https://stape.io/" versions: + - sha: 30d585a9569d27a77ddfbee8a2a2b67c97d105e7 + changeNotes: Getting Stape API key from headers. - sha: 4b06ca7c121f2908d84292a837b5704e1a61b42c changeNotes: Updated Stape API version, changed Google Auth, Googleads API v18. - sha: 45855bae28b8962d582d39911e1805fc980b5d79