Skip to main content

Hi All,

We are currently building an integration with Zapier. Our application uses Basic-Auth, and our clients have user-based domains/URL’s. We want to ensure that when the user completes authentication that the domain in the bundle is correct for that user and use it in our triggers and actions.

As part of the authentication step, we have built an endpoint that is called to retrieve the correct domain for that user. Is it possible to use this domain in the bundle? This is the code we have for the authentication step
 

const options = {
url: 'https://xxxxxxxxxx/getdomain',
method: 'GET',
params: {
username: bundle.authData.username,
},
};

//The response is the domain for the user. We validate on our side and return the domain for the user

return z.request(options)
.then((response) => {
response.throwForStatus();
const responseData = response.json;

// Concatenate the characters into a single string
const clientDomain = Object.values(responseData).join('');

// Add the clientUrl to the bundle to use in later stages.
//Can we set the domain here and use it in Triggers?
bundle.authData.domain = clientDomain;

// Return the clientUrl
return { clientDomain };

});

Here is an example response after successful authentication:

 

 

Can we set this clientDomain to the authData.domain property in the bundle, then access it from the Trigger?
 

const clientDomain = bundle.authData.domain;


We are not using the CLI at the moment.

Any help is greatly appreciated. Many thanks.

Hi @TMurray88,

 

Seeing that the ‘clientDomain’ was provided in the auth test, that value should be available in the inputData bundle. You can then reference it in your triggers using bundle.inputData.clientDomain.

I hope that helps.


Hi @Osas 

Thank you very much for your reply. We have updated our Trigger to use the “clientDomain” from the inputData bundle. However, we can see errors in the logs which is showing the domain as ‘undefined’.

Here is the updated code from our Trigger:
 

const clientDomain = bundle.inputData.clientDomain;

const options = {
url: `https://${clientDomain}/xxxxxxxx`,
method: 'GET',
headers: {
'Accept': 'application/json'
},
params: {
}
}

return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;

return results;
});


When we create a test Zap to test the trigger, we can see an error in the logs. It would seem as though the ‘clientDomain’ is not picking up the value from the inputData bundle? (We have hidden the rest of our URL after undefined in the screenshot below).

 



Is there a step that we are missing somewhere?

Many thanks.

​​​​​​​


Hi @TMurray88,

 

I see that there is a computed field for the domain on the integration and the computed field’s value has been specified to be the client domain from the auth test.

 

Due to that, you can reference this domain via ‘bundle.authData.domain’ in the triggers, and that should work.

 

If you require more assistance on this, you can reach out to our Developer Support team via https://developer.zapier.com/contact.


Hope that helps?

 

Cheers,


Thanks very much @Osas We will try this and we will reach out to Developer Support if we continue to have issues.

We appreciate the help very much.

Many thanks.


Reply