Skip to content

Commit

Permalink
Merge pull request #23 from stape-io/get_api_key_from_header
Browse files Browse the repository at this point in the history
Create stape api url from headers
  • Loading branch information
Bukashk0zzz authored Nov 15, 2024
2 parents e757f48 + 4d9ccf0 commit a4090a3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 42 deletions.
2 changes: 2 additions & 0 deletions metadata.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 4 additions & 9 deletions template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
82 changes: 49 additions & 33 deletions template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
]
},
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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"
}
]
}
]
}
Expand Down

0 comments on commit a4090a3

Please sign in to comment.