Pack credentials not being passed to API

I am stuck! Read all of the docs on auth, example, etc etc. Was able to get my first pack with makes a call to a third party service compiled and working but am getting “invalid credentials” from the response.

I have this section and I input my credentials from the Coda side:
pack.setUserAuthentication({
type: coda.AuthenticationType.WebBasic,

// Use placeholders for the username and password fields.
uxConfig: {
placeholderUsername: “User-ID”,
placeholderPassword: “API-Key”,
},
});

My fetcher looks like this:
let response = await context.fetcher.fetch({
method: “POST”,
url: “https://my-api-url-here”,
cacheTtlSecs: 0,
headers: {
“Content-Type”: “application/json”,
},
body: JSON.stringify(payload),
});
console.log(payload);
let data = response.body;

not sure what I am missing. Any help would be appreciated. I am trying to use basic auth and from what I can tell Coda does some encoding behind the scenes so i can’t print or view what is actually being passed.

I used postman with the same creds and was able to get this to work so I am pretty sure somewhere between the hand off from the coda doc to the API call… my creds are being dropped.

Hi @Mike_Alvarez - Sorry to hear about the trouble! The code looks good at first sight, so not sure why you are getting that error. Have you looked at the HTTP logs in the Pack Makers tools?

There you should be able to see more information about the outgoing request and if the API is returning a more specific error.

Thanks Eric! I have. Helpful but that is where I found the invalid credentials error: body:"<?xml version=\"1.0\" encoding=\"UTF-8\"?> <messages recipientcount="1">2022Invalid Credentials "

I understand why I Coda redacts the user name and password but it there any way to validate what is being passed?

My money is on this. Are you certain this is the authentication type the endpoint supports?

No, unfortunately there isn’t any way to validate it except for the API working :sweat_smile: To Bill’s point, can you show us what your settings look like for Postman?

Thanks guys for the engagement. Postman code snippet below. I changed the phone numbers as well as the encoded string (just in case) but you can see it is using basic.

var settings = {
“url”: "https://rest.clicksend.com/v3/sms/send?to=+11115551212&from=+18335551212&message=\“Postman says hi"”,
“method”: “POST”,
“timeout”: 0,
“headers”: {
“Content-Type”: “application/json”,
“Authorization”: “Basic bWlrZUBuZXV6ZWl0Z3-long-and-encoded-string-UU0QjJDRQ==”
},
“data”: JSON.stringify({
“messages”: [
{
“body”: “post man text”,
“to”: “+11115551212”,
“from”: “+18331231234”
}
]
}),
};

$.ajax(settings).done(function (response) {
console.log(response);
});

The end point I am calling says the credentials should be in the URL or post body.

Authentication

Your credentials should be used in the URL or the post body.
username - Your API username key - Your API key

Thanks for the responses @Eric_Koleda and @Bill_French. After going over this several times I finally discovered they changed the URL of their end point. They updated their postman files but not their documentation. It works now!

1 Like

Great sleuthing! It’s always something small and annoying like that. Glad you got it working!

1 Like

It sounds like you’ve made significant progress in setting up your pack, but you’re encountering issues with authentication and passing credentials to the API call. Let’s try to troubleshoot this together.

Firstly, ensure that the credentials you’re using (User-ID and API-Key) are correct and properly formatted. Double-check if there are any extra spaces or characters that might be causing authentication failures.

Next, let’s make sure that the authentication type and configuration are set up correctly in your pack. It looks like you’re using WebBasic authentication, which is suitable for basic authentication schemes. Make sure that the placeholderUsername and placeholderPassword match the field names expected by the API for authentication.

Since you mentioned that Coda might be encoding credentials behind the scenes, it’s essential to verify how the credentials are being passed in the actual API request. Unfortunately, as you mentioned, you can’t directly view the encoded credentials. However, you can check if the encoding process is causing any discrepancies between the credentials passed in Postman and those passed through your pack.

Lastly, consider reaching out to Coda’s support or community forums for further assistance. They might have insights or specific troubleshooting steps tailored to their platform that could help resolve the issue.

I hope these suggestions help you pinpoint and resolve the authentication issue. If you have any further questions or need additional assistance, feel free to ask!