Hello,
I’m currently working on a Clockify add-on that interacts with an API. I want the page to be able to load the API Key I’ve set in my add-on’s settings, through the URL query parameters, so my custom page can use the user’s API key for authenticated API requests.
Here is my current schema:
{
schemaVersion: '1.3',
key: 'addon-test',
name: 'Addon Test',
baseUrl: 'https://MY_API_URL',
minimalSubscriptionPlan: 'FREE',
components: [
{
type: 'team.tab',
label: 'My component',
path: '/clockify/edit_page?my_api_key=${apiKey}',
accessLevel: 'ADMINS'
}
],
settings: {
tabs: [
{
id: 'settings',
name: 'Settings',
settings: [
{
id: 'apiKey',
name: 'API key',
placeholder: 'API key',
description: 'Enter your API key here.',
value: 'ENTER_YOUR_API_KEY_HERE',
type: 'TXT',
required: true,
copyable: false,
readOnly: false,
accessLevel: 'ADMINS'
}
]
}
]
}
}
With this schema, when I load the iframe, the URL has a malformed query string that looks like this: https://MY_API_URL/clockify/edit_page?my_api_key=ENTER_YOUR_API_KEY_HERE?auth_token=clockify_auth_token&userId=clockify_user_id&initialUrl=/teams
.
I could pass the API key in the URL directly (/clockify/edit_page/${apiKey}
), however this makes it more difficult to update my app if I have to add more parameters in my component, and even harder if the app becomes used by other Clockify users.
Is there another way to properly insert custom query parameters in the components URL ? Or should I stick to passing my own API Key directly in the URL ?
Thanks in advance,
Rémi