Can I use setUserAuthentication and setSystemAuthentication together in a pack?

I want to ask can we set 2 different authentication in a pack? Like the code below, I want to have ability to identify by user based on bearer token, and I also want to access some key that use for all user.

export const pack = coda.newPack();

pack.addNetworkDomain(config.domain);
pack.setSystemAuthentication({
  type: coda.AuthenticationType.Custom,
  params: [
    {name: "security_key", description: "The Security Key"},
  ],
});
pack.setUserAuthentication({
  type: coda.AuthenticationType.HeaderBearerToken,
});

If I do this, I notice I won’t able to retrieve the key value, instead of the real value, it just return me
“{{key-1234}}”. After I remove the setUserAuthentication, the real value will show.

Any idea I can fix this? Thanks.

Hi @Jowin_Yip - Welcome to the Coda Community, and excited to hear you are working on a Pack. You can add both system and user authentication to a Pack, but any given Fetcher request can only use one or the other. Whether the user or system authentication is used it determined by the formula’s connectionRequirement, which is outlined here:

There unfortunately isn’t any way to blend system and user authentication together in the same request. However, as a workaround you can hard code your security key in your code and manually add it to each outgoing request.

1 Like