How do I configure basic authentication credentials when calling an external API?
I am trying to create a shipping order in bpack (bpost) API. Basic authentication is required.
The below configuration does not work. The response that I get is that "This request requires HTTP authentication".
I have successfully tested the credentials in Hoppscotch testing tool. I am sure about the url, content-type, accept, username and passphrase values.
My issue is that I do not find any online resources that covers basic authentication.
Do I need to transform/encode the username and passphrase? Could someone point me in the right direction?
Best Answer
-
Basic auth is a header made of:
Authorization: Basic BASE64TOKEN
BASE64TOKEN is a string made of the username, then a colon, and then the password, with the resulting string getting with a base64_encode filter applied to it.
So you'd start with the username:password (in your case it becomes 123456:48676dc21f)
And then we base64 the result. I for demonstration, i used Cyberchef for this job:
I got the result MTIzNDU2OjQ4Njc2ZGMyMWY=
That brings me to the final version of our Auth header:
Authorization: Basic MTIzNDU2OjQ4Njc2ZGMyMWY=
You can use cyberchef like I did to do this statically, and Xano gives you tools to do it dynamically with its filters as well.
You can learn more about Basic authentication on MDN:Dealing with APIs - especially authentication - is often part of the hardest 5% we focus on in our daily office hours and loom-based forums on State Change.
Answers
-
Hi Ray,
Thank you for the advice.
It worked! It feels good :-)
I have another hurdle to surpass. It is about passing XML context in the parameters.
I will check the discussions before making a new post.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback